Re: Single thread creation queue?

2021-11-24 Thread Paul Hoadley via Webobjects-dev
On 25 Nov 2021, at 01:11, Jesse Tayler  wrote:

> A collation would also work, I don’t think there’s a need to preserve case 
> but I guess I have thus far and perhaps that’s an easier route than 
> attempting to alter data in place, I could simply add the function in a way 
> it can blend in perhaps.

An additional option if you're using PostgreSQL (though you've hinted that 
you're not) is using the CITEXT extension type on the column:

https://www.postgresql.org/docs/13/citext.html

We've been using this on, for example, user-supplied email addresses as login 
identifiers for several years now. It lets you preserve the user-supplied case, 
but ignores it for comparisons.

> I tried to find a decent wiki page, but does anyone have good examples of 
> migrations that add constraints or do fancy stuff? 
> 
> Do I have to stuff raw SQL into a migration or are there functions I can’t 
> see in there--

You'll need to stuff raw SQL into a migration. There are several ways to do it, 
and here's one of them. In upgrade():

ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), "ALTER TABLE foo ADD 
CONSTRAINT bar_unique UNIQUE (bar) DEFERRABLE INITIALLY DEFERRED;");

That's PostgreSQL syntax, and you might need to adjust it for another database.


-- 
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-24 Thread Theodore Petrosky via Webobjects-dev
If I had the model and understood what you were looking for I might be able to 
figure it out.



> On Nov 24, 2021, at 3:17 PM, Jesse Tayler via Webobjects-dev 
>  wrote:
> 
> Thanks Ted, actually I was looking to see how to make a compound constraint - 
> one static string type=“twitter” and I guess a lowercase version of a 
> user-entered display string keyStringToLowercase = username and the only way 
> I saw to add that into migrations was to write SQL and inject it?
> 
> But I did NOT know how to adjust those error strings! I have several 
> bothersome error reports so, you’ve opened my eyes! I’ll look into that 
> .strings key stuff there and see if I can figure that out. I might ping you 
> about it...
> 
>> On Nov 24, 2021, at 2:43 PM, Theodore Petrosky  
>> wrote:
>> 
>> An example of a migration:
>> Postgresql throws the exception then in ValidationException.strings I have:
>> {
>>   "UniqueConstraintException.login_idx" = "Please choose a different 
>> login (It must be unique).";
>> 
>>   "Quote.quoteAmount"="You must enter a dollar amount in the format 
>> 123.00 (you entered @@escapedValue@@)!";
>> 
>> }
>> To present readable error.
>> Is this what you are looking for?
>> 
>> ERXMigrationTable personTable = database.newTableNamed("Person");
>>  personTable.newFlagBooleanColumn("active", NOT_NULL);
>>  personTable.newLargeStringColumn("addressline1", ALLOWS_NULL);
>>  personTable.newLargeStringColumn("addressline2", ALLOWS_NULL);
>>  personTable.newLargeStringColumn("city", ALLOWS_NULL);
>>  personTable.newDateColumn("creationdate", NOT_NULL);
>>  personTable.newIntegerColumn("financialID", NOT_NULL);
>>  personTable.newLargeStringColumn("firstname", NOT_NULL);
>>  personTable.newIntegerColumn("id", NOT_NULL);
>>  personTable.newLargeStringColumn("lastname", NOT_NULL);
>>  personTable.newLargeStringColumn("login", ALLOWS_NULL);
>>  personTable.newLargeStringColumn("password", ALLOWS_NULL);
>>  personTable.newIntegerColumn("securityID", NOT_NULL);
>>  personTable.newLargeStringColumn("state", ALLOWS_NULL);
>>  personTable.newLargeStringColumn("zipcode", ALLOWS_NULL);
>>  personTable.create();
>>  personTable.setPrimaryKey("id");
>>  personTable.addIndex(new ERXMigrationIndex(
>> "login_idx", true 
>> ,new ColumnIndex("login")
>>  ));
>> 
>> 
>> From: "Ted Petrosky (WO)" 
>> Reply-To: Jesse Tayler 
>> Date: Wednesday, November 24, 2021 at 9:41 AM
>> To: Samuel Pelletier 
>> Cc: "Ted Petrosky (WO)" 
>> Subject: Re: Single thread creation queue?
>> 
>> A collation would also work, I don’t think there’s a need to preserve case 
>> but I guess I have thus far and perhaps that’s an easier route than 
>> attempting to alter data in place, I could simply add the function in a way 
>> it can blend in perhaps.
>> 
>> I tried to find a decent wiki page, but does anyone have good examples of 
>> migrations that add constraints or do fancy stuff? 
>> 
>> Do I have to stuff raw SQL into a migration or are there functions I can’t 
>> see in there--
>> 
>> 
>>> On Nov 24, 2021, at 8:52 AM, Samuel Pelletier  wrote:
>>> 
>>> Jesse,
>>> 
>>> If you specify a case insensitive collation for your column in the table, 
>>> you can preserve case and maintains case insensitive uniqueness. If you do 
>>> not know about collation, begin by reading on the subject, they basically 
>>> define how to compare and sort strings values.
>>> 
>>> Depending on the probability of duplicate and how you want to handle this 
>>> problem, you can try-catch or pre check before saving, you probably prefer 
>>> try-catch because it save a round-trip to the database. Tu use try-catch, 
>>> you need the contraint in the database though.
>>> 
>>> Samuel
>>> 
>>> 
>>>> Le 24 nov. 2021 à 08:02, Jesse Tayler  a écrit :
>>>> 
>>>> so, basically, you are suggesting that I store them flat lowercase and put 
>>>> a constraint on these two strings and just lose any case the 

Re: Single thread creation queue?

2021-11-24 Thread Jesse Tayler via Webobjects-dev
Thanks Ted, actually I was looking to see how to make a compound constraint - 
one static string type=“twitter” and I guess a lowercase version of a 
user-entered display string keyStringToLowercase = username and the only way I 
saw to add that into migrations was to write SQL and inject it?

But I did NOT know how to adjust those error strings! I have several bothersome 
error reports so, you’ve opened my eyes! I’ll look into that .strings key stuff 
there and see if I can figure that out. I might ping you about it...

> On Nov 24, 2021, at 2:43 PM, Theodore Petrosky  
> wrote:
> 
> An example of a migration:
> Postgresql throws the exception then in ValidationException.strings I have:
> {
>"UniqueConstraintException.login_idx" = "Please choose a different 
> login (It must be unique).";
>
>"Quote.quoteAmount"="You must enter a dollar amount in the format 
> 123.00 (you entered @@escapedValue@@)!";
>
> }
> To present readable error.
> Is this what you are looking for?
>  
> ERXMigrationTable personTable = database.newTableNamed("Person");
>   personTable.newFlagBooleanColumn("active", NOT_NULL);
>   personTable.newLargeStringColumn("addressline1", ALLOWS_NULL);
>   personTable.newLargeStringColumn("addressline2", ALLOWS_NULL);
>   personTable.newLargeStringColumn("city", ALLOWS_NULL);
>   personTable.newDateColumn("creationdate", NOT_NULL);
>   personTable.newIntegerColumn("financialID", NOT_NULL);
>   personTable.newLargeStringColumn("firstname", NOT_NULL);
>   personTable.newIntegerColumn("id", NOT_NULL);
>   personTable.newLargeStringColumn("lastname", NOT_NULL);
>   personTable.newLargeStringColumn("login", ALLOWS_NULL);
>   personTable.newLargeStringColumn("password", ALLOWS_NULL);
>   personTable.newIntegerColumn("securityID", NOT_NULL);
>   personTable.newLargeStringColumn("state", ALLOWS_NULL);
>   personTable.newLargeStringColumn("zipcode", ALLOWS_NULL);
>   personTable.create();
>   personTable.setPrimaryKey("id");
>   personTable.addIndex(new ERXMigrationIndex(
>  "login_idx", true 
>  ,new ColumnIndex("login")
>   ));
>  
>  
> From: "Ted Petrosky (WO)" 
> Reply-To: Jesse Tayler 
> Date: Wednesday, November 24, 2021 at 9:41 AM
> To: Samuel Pelletier 
> Cc: "Ted Petrosky (WO)" 
> Subject: Re: Single thread creation queue?
>  
> A collation would also work, I don’t think there’s a need to preserve case 
> but I guess I have thus far and perhaps that’s an easier route than 
> attempting to alter data in place, I could simply add the function in a way 
> it can blend in perhaps.
>  
> I tried to find a decent wiki page, but does anyone have good examples of 
> migrations that add constraints or do fancy stuff? 
>  
> Do I have to stuff raw SQL into a migration or are there functions I can’t 
> see in there--
> 
> 
>> On Nov 24, 2021, at 8:52 AM, Samuel Pelletier  wrote:
>>  
>> Jesse,
>>  
>> If you specify a case insensitive collation for your column in the table, 
>> you can preserve case and maintains case insensitive uniqueness. If you do 
>> not know about collation, begin by reading on the subject, they basically 
>> define how to compare and sort strings values.
>>  
>> Depending on the probability of duplicate and how you want to handle this 
>> problem, you can try-catch or pre check before saving, you probably prefer 
>> try-catch because it save a round-trip to the database. Tu use try-catch, 
>> you need the contraint in the database though.
>>  
>> Samuel
>> 
>> 
>>> Le 24 nov. 2021 à 08:02, Jesse Tayler  a écrit :
>>>  
>>> so, basically, you are suggesting that I store them flat lowercase and put 
>>> a constraint on these two strings and just lose any case the user entered 
>>> which is fine I think.
>>>  
>>> With the lowercase assured the constraint will prevent duplicates and I’d 
>>> catch that exception during creation and handle it
>>> 
>>> 
>>>> On Nov 24, 2021, at 12:19 AM, Samuel Pelletier  wrote:
>>>>  
>>>> If your usernames (or keyString) are case insensitive, store them in a 
>>>> normalized case (in lowercase for exemple). 
>>>>  

Re: Single thread creation queue?

2021-11-24 Thread Theodore Petrosky via Webobjects-dev
An example of a migration:
Postgresql throws the exception then in ValidationException.strings I have:
{
   "UniqueConstraintException.login_idx" = "Please choose a different login 
(It must be unique).";

   "Quote.quoteAmount"="You must enter a dollar amount in the format 123.00 
(you entered @@escapedValue@@)!";

}
To present readable error.
Is this what you are looking for?


ERXMigrationTable personTable = database.newTableNamed("Person");

  personTable.newFlagBooleanColumn("active", NOT_NULL);

  personTable.newLargeStringColumn("addressline1", ALLOWS_NULL);

  personTable.newLargeStringColumn("addressline2", ALLOWS_NULL);

  personTable.newLargeStringColumn("city", ALLOWS_NULL);

  personTable.newDateColumn("creationdate", NOT_NULL);

  personTable.newIntegerColumn("financialID", NOT_NULL);

  personTable.newLargeStringColumn("firstname", NOT_NULL);

  personTable.newIntegerColumn("id", NOT_NULL);

  personTable.newLargeStringColumn("lastname", NOT_NULL);

  personTable.newLargeStringColumn("login", ALLOWS_NULL);

  personTable.newLargeStringColumn("password", ALLOWS_NULL);

  personTable.newIntegerColumn("securityID", NOT_NULL);

  personTable.newLargeStringColumn("state", ALLOWS_NULL);

  personTable.newLargeStringColumn("zipcode", ALLOWS_NULL);

  personTable.create();

  personTable.setPrimaryKey("id");

  personTable.addIndex(new ERXMigrationIndex(

 "login_idx", true

     ,new ColumnIndex("login")

  ));


From: "Ted Petrosky (WO)" 
Reply-To: Jesse Tayler 
Date: Wednesday, November 24, 2021 at 9:41 AM
To: Samuel Pelletier 
Cc: "Ted Petrosky (WO)" 
Subject: Re: Single thread creation queue?

A collation would also work, I don’t think there’s a need to preserve case but 
I guess I have thus far and perhaps that’s an easier route than attempting to 
alter data in place, I could simply add the function in a way it can blend in 
perhaps.

I tried to find a decent wiki page, but does anyone have good examples of 
migrations that add constraints or do fancy stuff?

Do I have to stuff raw SQL into a migration or are there functions I can’t see 
in there--


On Nov 24, 2021, at 8:52 AM, Samuel Pelletier 
mailto:sam...@samkar.com>> wrote:

Jesse,

If you specify a case insensitive collation for your column in the table, you 
can preserve case and maintains case insensitive uniqueness. If you do not know 
about collation, begin by reading on the subject, they basically define how to 
compare and sort strings values.

Depending on the probability of duplicate and how you want to handle this 
problem, you can try-catch or pre check before saving, you probably prefer 
try-catch because it save a round-trip to the database. Tu use try-catch, you 
need the contraint in the database though.

Samuel


Le 24 nov. 2021 à 08:02, Jesse Tayler 
mailto:jtay...@oeinc.com>> a écrit :

so, basically, you are suggesting that I store them flat lowercase and put a 
constraint on these two strings and just lose any case the user entered which 
is fine I think.

With the lowercase assured the constraint will prevent duplicates and I’d catch 
that exception during creation and handle it


On Nov 24, 2021, at 12:19 AM, Samuel Pelletier 
mailto:sam...@samkar.com>> wrote:

If your usernames (or keyString) are case insensitive, store them in a 
normalized case (in lowercase for exemple).

You can add an overridden
public void setKeyString(String value) {
if (value != null) {
value = value.toLowerCase();
}
super.setKeyString(value);
}

You may also specify a collation to the column in the database if you want to 
preserve case but index and compare as case insensitive.

Samuel


Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
mailto:webobjects-dev@lists.apple.com>> a écrit 
:




On Nov 23, 2021, at 5:17 PM, Paul Hoadley 
mailto:pa...@logicsquad.net>> wrote:

Are you able to paste in some code? There's probably a solution, but this is 
getting a bit hard to follow in the abstract.


So, I fetch first

EOQualifier qual = 
DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));

If there’s no EO, I create and save right away but at high volumes this CREATE 
statement must create only unique entries and those entries must match this 
qualifier which uses insensitive case

I figure the pattern should be to create an object with a DB level constraint 
such that a duplicate raises an error, upon catching that error, I can simply 
fetch again and return the one

Re: Single thread creation queue?

2021-11-24 Thread Jesse Tayler via Webobjects-dev
A collation would also work, I don’t think there’s a need to preserve case but 
I guess I have thus far and perhaps that’s an easier route than attempting to 
alter data in place, I could simply add the function in a way it can blend in 
perhaps.

I tried to find a decent wiki page, but does anyone have good examples of 
migrations that add constraints or do fancy stuff? 

Do I have to stuff raw SQL into a migration or are there functions I can’t see 
in there--

> On Nov 24, 2021, at 8:52 AM, Samuel Pelletier  wrote:
> 
> Jesse,
> 
> If you specify a case insensitive collation for your column in the table, you 
> can preserve case and maintains case insensitive uniqueness. If you do not 
> know about collation, begin by reading on the subject, they basically define 
> how to compare and sort strings values.
> 
> Depending on the probability of duplicate and how you want to handle this 
> problem, you can try-catch or pre check before saving, you probably prefer 
> try-catch because it save a round-trip to the database. Tu use try-catch, you 
> need the contraint in the database though.
> 
> Samuel
> 
>> Le 24 nov. 2021 à 08:02, Jesse Tayler > > a écrit :
>> 
>> so, basically, you are suggesting that I store them flat lowercase and put a 
>> constraint on these two strings and just lose any case the user entered 
>> which is fine I think.
>> 
>> With the lowercase assured the constraint will prevent duplicates and I’d 
>> catch that exception during creation and handle it
>> 
>>> On Nov 24, 2021, at 12:19 AM, Samuel Pelletier >> > wrote:
>>> 
>>> If your usernames (or keyString) are case insensitive, store them in a 
>>> normalized case (in lowercase for exemple). 
>>> 
>>> You can add an overridden 
>>> public void setKeyString(String value) {
>>> if (value != null) {
>>> value = value.toLowerCase();
>>> }
>>> super.setKeyString(value);
>>> }
>>> 
>>> You may also specify a collation to the column in the database if you want 
>>> to preserve case but index and compare as case insensitive.
>>> 
>>> Samuel
>>> 
 Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
 mailto:webobjects-dev@lists.apple.com>> a 
 écrit :
 
 
 
> On Nov 23, 2021, at 5:17 PM, Paul Hoadley  > wrote:
> 
> Are you able to paste in some code? There's probably a solution, but this 
> is getting a bit hard to follow in the abstract.
> 
 
 So, I fetch first
 
EOQualifier qual = 
 DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));
 
 If there’s no EO, I create and save right away but at high volumes this 
 CREATE statement must create only unique entries and those entries must 
 match this qualifier which uses insensitive case
 
 I figure the pattern should be to create an object with a DB level 
 constraint such that a duplicate raises an error, upon catching that 
 error, I can simply fetch again and return the one, single EO representing 
 that record
 
 When I tried regular constraints I did not see a way to replicate the 
 required logic, so I found some advise about triggers and some other 
 things I didn’t fully understand.
 
 I realize usernames generally have this kind of issue, so I figure this is 
 a design pattern that is hardly unique to us and I should get advice!
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com 
 )
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com 
 
 
 This email sent to sam...@samkar.com 
>>> 
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-24 Thread Samuel Pelletier via Webobjects-dev
Jesse,

If you specify a case insensitive collation for your column in the table, you 
can preserve case and maintains case insensitive uniqueness. If you do not know 
about collation, begin by reading on the subject, they basically define how to 
compare and sort strings values.

Depending on the probability of duplicate and how you want to handle this 
problem, you can try-catch or pre check before saving, you probably prefer 
try-catch because it save a round-trip to the database. Tu use try-catch, you 
need the contraint in the database though.

Samuel

> Le 24 nov. 2021 à 08:02, Jesse Tayler  a écrit :
> 
> so, basically, you are suggesting that I store them flat lowercase and put a 
> constraint on these two strings and just lose any case the user entered which 
> is fine I think.
> 
> With the lowercase assured the constraint will prevent duplicates and I’d 
> catch that exception during creation and handle it
> 
>> On Nov 24, 2021, at 12:19 AM, Samuel Pelletier > > wrote:
>> 
>> If your usernames (or keyString) are case insensitive, store them in a 
>> normalized case (in lowercase for exemple). 
>> 
>> You can add an overridden 
>> public void setKeyString(String value) {
>>  if (value != null) {
>>  value = value.toLowerCase();
>>  }
>>  super.setKeyString(value);
>> }
>> 
>> You may also specify a collation to the column in the database if you want 
>> to preserve case but index and compare as case insensitive.
>> 
>> Samuel
>> 
>>> Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
>>> mailto:webobjects-dev@lists.apple.com>> a 
>>> écrit :
>>> 
>>> 
>>> 
 On Nov 23, 2021, at 5:17 PM, Paul Hoadley >>> > wrote:
 
 Are you able to paste in some code? There's probably a solution, but this 
 is getting a bit hard to follow in the abstract.
 
>>> 
>>> So, I fetch first
>>> 
>>> EOQualifier qual = 
>>> DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));
>>> 
>>> If there’s no EO, I create and save right away but at high volumes this 
>>> CREATE statement must create only unique entries and those entries must 
>>> match this qualifier which uses insensitive case
>>> 
>>> I figure the pattern should be to create an object with a DB level 
>>> constraint such that a duplicate raises an error, upon catching that error, 
>>> I can simply fetch again and return the one, single EO representing that 
>>> record
>>> 
>>> When I tried regular constraints I did not see a way to replicate the 
>>> required logic, so I found some advise about triggers and some other things 
>>> I didn’t fully understand.
>>> 
>>> I realize usernames generally have this kind of issue, so I figure this is 
>>> a design pattern that is hardly unique to us and I should get advice!
>>> 
>>> ___
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com 
>>> )
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com 
>>> 
>>> 
>>> This email sent to sam...@samkar.com 
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-24 Thread George Domurot via Webobjects-dev
Hi Jesse,

We often have a someValue_unique attribute that is set when the main editable 
version of it is set. It isn’t editable by the user directly, but is adjusted 
when the other value is update — and it is used for uniquing, i.e.:

public void setSomeValue(String value){ super.setSomeValue(value); 
_cleanupSomeValue_unique(); }

-G

> On Nov 24, 2021, at 5:02 AM, Jesse Tayler via Webobjects-dev 
>  wrote:
> 
> so, basically, you are suggesting that I store them flat lowercase and put a 
> constraint on these two strings and just lose any case the user entered which 
> is fine I think.
> 
> With the lowercase assured the constraint will prevent duplicates and I’d 
> catch that exception during creation and handle it
> 
>> On Nov 24, 2021, at 12:19 AM, Samuel Pelletier > > wrote:
>> 
>> If your usernames (or keyString) are case insensitive, store them in a 
>> normalized case (in lowercase for exemple). 
>> 
>> You can add an overridden 
>> public void setKeyString(String value) {
>>  if (value != null) {
>>  value = value.toLowerCase();
>>  }
>>  super.setKeyString(value);
>> }
>> 
>> You may also specify a collation to the column in the database if you want 
>> to preserve case but index and compare as case insensitive.
>> 
>> Samuel
>> 
>>> Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
>>> mailto:webobjects-dev@lists.apple.com>> a 
>>> écrit :
>>> 
>>> 
>>> 
 On Nov 23, 2021, at 5:17 PM, Paul Hoadley >>> > wrote:
 
 Are you able to paste in some code? There's probably a solution, but this 
 is getting a bit hard to follow in the abstract.
 
>>> 
>>> So, I fetch first
>>> 
>>> EOQualifier qual = 
>>> DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));
>>> 
>>> If there’s no EO, I create and save right away but at high volumes this 
>>> CREATE statement must create only unique entries and those entries must 
>>> match this qualifier which uses insensitive case
>>> 
>>> I figure the pattern should be to create an object with a DB level 
>>> constraint such that a duplicate raises an error, upon catching that error, 
>>> I can simply fetch again and return the one, single EO representing that 
>>> record
>>> 
>>> When I tried regular constraints I did not see a way to replicate the 
>>> required logic, so I found some advise about triggers and some other things 
>>> I didn’t fully understand.
>>> 
>>> I realize usernames generally have this kind of issue, so I figure this is 
>>> a design pattern that is hardly unique to us and I should get advice!
>>> 
>>> ___
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com 
>>> )
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com 
>>> 
>>> 
>>> This email sent to sam...@samkar.com 
>> 
> 
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/g%40knuckleheads.net
> 
> This email sent to g...@knuckleheads.net

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-24 Thread Jesse Tayler via Webobjects-dev
so, basically, you are suggesting that I store them flat lowercase and put a 
constraint on these two strings and just lose any case the user entered which 
is fine I think.

With the lowercase assured the constraint will prevent duplicates and I’d catch 
that exception during creation and handle it

> On Nov 24, 2021, at 12:19 AM, Samuel Pelletier  wrote:
> 
> If your usernames (or keyString) are case insensitive, store them in a 
> normalized case (in lowercase for exemple). 
> 
> You can add an overridden 
> public void setKeyString(String value) {
>   if (value != null) {
>   value = value.toLowerCase();
>   }
>   super.setKeyString(value);
> }
> 
> You may also specify a collation to the column in the database if you want to 
> preserve case but index and compare as case insensitive.
> 
> Samuel
> 
>> Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
>> mailto:webobjects-dev@lists.apple.com>> a 
>> écrit :
>> 
>> 
>> 
>>> On Nov 23, 2021, at 5:17 PM, Paul Hoadley >> > wrote:
>>> 
>>> Are you able to paste in some code? There's probably a solution, but this 
>>> is getting a bit hard to follow in the abstract.
>>> 
>> 
>> So, I fetch first
>> 
>>  EOQualifier qual = 
>> DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));
>> 
>> If there’s no EO, I create and save right away but at high volumes this 
>> CREATE statement must create only unique entries and those entries must 
>> match this qualifier which uses insensitive case
>> 
>> I figure the pattern should be to create an object with a DB level 
>> constraint such that a duplicate raises an error, upon catching that error, 
>> I can simply fetch again and return the one, single EO representing that 
>> record
>> 
>> When I tried regular constraints I did not see a way to replicate the 
>> required logic, so I found some advise about triggers and some other things 
>> I didn’t fully understand.
>> 
>> I realize usernames generally have this kind of issue, so I figure this is a 
>> design pattern that is hardly unique to us and I should get advice!
>> 
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com 
>> )
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com 
>> 
>> 
>> This email sent to sam...@samkar.com
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-23 Thread Samuel Pelletier via Webobjects-dev
If your usernames (or keyString) are case insensitive, store them in a 
normalized case (in lowercase for exemple). 

You can add an overridden 
public void setKeyString(String value) {
if (value != null) {
value = value.toLowerCase();
}
super.setKeyString(value);
}

You may also specify a collation to the column in the database if you want to 
preserve case but index and compare as case insensitive.

Samuel

> Le 23 nov. 2021 à 17:26, Jesse Tayler via Webobjects-dev 
>  a écrit :
> 
> 
> 
>> On Nov 23, 2021, at 5:17 PM, Paul Hoadley > > wrote:
>> 
>> Are you able to paste in some code? There's probably a solution, but this is 
>> getting a bit hard to follow in the abstract.
>> 
> 
> So, I fetch first
> 
>   EOQualifier qual = 
> DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));
> 
> If there’s no EO, I create and save right away but at high volumes this 
> CREATE statement must create only unique entries and those entries must match 
> this qualifier which uses insensitive case
> 
> I figure the pattern should be to create an object with a DB level constraint 
> such that a duplicate raises an error, upon catching that error, I can simply 
> fetch again and return the one, single EO representing that record
> 
> When I tried regular constraints I did not see a way to replicate the 
> required logic, so I found some advise about triggers and some other things I 
> didn’t fully understand.
> 
> I realize usernames generally have this kind of issue, so I figure this is a 
> design pattern that is hardly unique to us and I should get advice!
> 
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-23 Thread Jesse Tayler via Webobjects-dev


> On Nov 23, 2021, at 5:17 PM, Paul Hoadley  wrote:
> 
> Are you able to paste in some code? There's probably a solution, but this is 
> getting a bit hard to follow in the abstract.
> 

So, I fetch first

EOQualifier qual = 
DataPoint.TYPE.eq("twitter").and(DataPoint.KEY_STRING.likeInsensitive(username));

If there’s no EO, I create and save right away but at high volumes this CREATE 
statement must create only unique entries and those entries must match this 
qualifier which uses insensitive case

I figure the pattern should be to create an object with a DB level constraint 
such that a duplicate raises an error, upon catching that error, I can simply 
fetch again and return the one, single EO representing that record

When I tried regular constraints I did not see a way to replicate the required 
logic, so I found some advise about triggers and some other things I didn’t 
fully understand.

I realize usernames generally have this kind of issue, so I figure this is a 
design pattern that is hardly unique to us and I should get advice!

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-23 Thread Paul Hoadley via Webobjects-dev
Hi Jesse,

On 24 Nov 2021, at 03:19, Jesse Tayler via Webobjects-dev 
 wrote:

> Ok wait — I have a question
> 
> I see my qualifier and the constraint needs to be equivalent 
> 
> The qualifier has one fixed string and the second string is — 
> case-insensitive — constraints don’t seem to allow this notion?
> 
> I see a several suggestions on what is clearly the same, common issue - often 
> usernames have this quality
> 
> https://stackoverflow.com/questions/637030/lowercase-constraint-sql-server
> 
> Anyone have insight?

Are you able to paste in some code? There's probably a solution, but this is 
getting a bit hard to follow in the abstract.


-- 
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-23 Thread Jesse Tayler via Webobjects-dev
Ok wait — I have a question

I see my qualifier and the constraint needs to be equivalent 

The qualifier has one fixed string and the second string is — case-insensitive 
— constraints don’t seem to allow this notion?

I see a several suggestions on what is clearly the same, common issue - often 
usernames have this quality

https://stackoverflow.com/questions/637030/lowercase-constraint-sql-server

Anyone have insight?



> On Nov 22, 2021, at 10:07 AM, Samuel Pelletier  wrote:
> 
> Jesse,
> 
> So your row have a primary key and some other unique identifier derived other 
> attributes.
> 
> If the compound key is a combinaison of full attribute values, you cana a 
> compound unique key in the database. CREATE UNIQUE INDEX ON Table (col1, 
> col2, ..., coln)
> 
> If it is from partial values, the most reliable way is to add a string column 
> with the computed key with it's unique constraint.
> 
> If you already have duplicate, you can add a method in the migration to 
> resolve them before adding the constraint or do it manually...
> 
> Regards,
> 
> Samuel
> 
>> Le 22 nov. 2021 à 09:27, Jesse Tayler  a écrit :
>> 
>> It’s likely just a unique constraint perhaps.
>> 
>> It’s not UIDs or primary keys it’s a unique row type based on a couple 
>> strings where there should be only one, and that one should last forever.
>> 
>> There’s an API where calls can come in basically at the same time and 
>> instead of fetching first to see if the object exists, I should likely 
>> respond to an SQL error rejecting a new row and then fetch and return that 
>> existing object based on that error condition.
>> 
>> I’d suppose the database is the best place for that policy, but I don’t 
>> think I’ve implemented constraints quite like that before so I’d need to 
>> write some sort of Migrations for it if it’s to be reliable in all those 
>> situations where it might encounter duplicate data…hmmm…
>> 
>> 
>> 
>> 
>>> On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
>>> 
>>> Hi Jesse,
>>> 
>>> Your question may have multiple answers, can you describe the contexts and 
>>> duplicate sources you fear ?
>>> 
>>> Is the primary key generated by the WO app or it is external (like a GUID) ?
>>> 
>>> Do you have a secondary identifier that should be unique ?
>>> 
>>> Anyway, you should add constraint in to the database if uniqueness is 
>>> required (this apply to all frameworks in all language)
>>> 
>>> If you use EOF primary key generation, you should not have problems with 
>>> duplicate keys. If you require high throughput, using UUID primary key or 
>>> implementing a custom generator will help by saving round trips to the 
>>> database server. If you insert in batch, it will be also faster than 
>>> individual inserts.
>>> 
>>> Regards,
>>> 
>>> Samuel
>>> 
 Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
  a écrit :
 
 I asked on slack but I figured I’d ping the list
 
 Who has a good way to ensure a serial EO creation queue when the system 
 could be hit really fast and you must avoid duplicate entries?
 
 I’m a bit surprised I don’t recall EOF style solutions for such things and 
 maybe the Amazon RDS database has a shared connection pattern the apps can 
 use, I didn’t see anything so I figure this is application level stuff.
 
 Thoughts? Suggestions?
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
 
 This email sent to sam...@samkar.com
>>> 
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Jesse Tayler via Webobjects-dev
Oh? Thanks - I hadn’t heard of such a thing. This would be Amazon RDS which is 
basically MySQL and likely has similar.

Either way I guess I should delete any dups, they either cause an error 
somewhere or at least integrity problems I don’t need.

Is there a good wiki page on migration examples out there?



> On Nov 22, 2021, at 11:19 AM, Aaron Rosenzweig  wrote:
> 
> Sounds like you are using Postgres?
> 
> You can use the syntax “not valid” when you create a constraint to stop the 
> bleeding immediately. It will then only check for new and modified records 
> allowing the bad rows to co-exist. When you get around to it, you can remove 
> the duplicates. 
> 
> If it’s another database, they likely have something similar. 
> 
>> On Nov 22, 2021, at 10:18 AM, Jesse Tayler  wrote:
>> 
>> It’s not a compound key so much as just policy — it’s a handle for social 
>> service and so there should just be one row with that value and don’t need 
>> to tie into the key
>> 
>> I guess I can create a unique index just for that one attribute and it would 
>> presumedly return an error upon save. I should re-write the EO to handle 
>> that error raise and respond by returning the existing object…
>> 
>> I guess that is not hard to figure if that approach sounds sane.
>> 
>> I do have dups and I’d guess the constraint will simply fail if the database 
>> has any dups in it.
>> 
>> I guess writing a migration to handle / remove dups is not practical so I’d 
>> likely remove them by hand, then add the constraint in a migration update 
>> that would gently fail until there are no more dups…
>> 
>> 
>> 
>>> On Nov 22, 2021, at 10:07 AM, Samuel Pelletier  wrote:
>>> 
>>> Jesse,
>>> 
>>> So your row have a primary key and some other unique identifier derived 
>>> other attributes.
>>> 
>>> If the compound key is a combinaison of full attribute values, you cana a 
>>> compound unique key in the database. CREATE UNIQUE INDEX ON Table (col1, 
>>> col2, ..., coln)
>>> 
>>> If it is from partial values, the most reliable way is to add a string 
>>> column with the computed key with it's unique constraint.
>>> 
>>> If you already have duplicate, you can add a method in the migration to 
>>> resolve them before adding the constraint or do it manually...
>>> 
>>> Regards,
>>> 
>>> Samuel
>>> 
 Le 22 nov. 2021 à 09:27, Jesse Tayler  a écrit :
 
 It’s likely just a unique constraint perhaps.
 
 It’s not UIDs or primary keys it’s a unique row type based on a couple 
 strings where there should be only one, and that one should last forever.
 
 There’s an API where calls can come in basically at the same time and 
 instead of fetching first to see if the object exists, I should likely 
 respond to an SQL error rejecting a new row and then fetch and return that 
 existing object based on that error condition.
 
 I’d suppose the database is the best place for that policy, but I don’t 
 think I’ve implemented constraints quite like that before so I’d need to 
 write some sort of Migrations for it if it’s to be reliable in all those 
 situations where it might encounter duplicate data…hmmm…
 
 
 
 
> On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
> 
> Hi Jesse,
> 
> Your question may have multiple answers, can you describe the contexts 
> and duplicate sources you fear ?
> 
> Is the primary key generated by the WO app or it is external (like a 
> GUID) ?
> 
> Do you have a secondary identifier that should be unique ?
> 
> Anyway, you should add constraint in to the database if uniqueness is 
> required (this apply to all frameworks in all language)
> 
> If you use EOF primary key generation, you should not have problems with 
> duplicate keys. If you require high throughput, using UUID primary key or 
> implementing a custom generator will help by saving round trips to the 
> database server. If you insert in batch, it will be also faster than 
> individual inserts.
> 
> Regards,
> 
> Samuel
> 
>> Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
>>  a écrit :
>> 
>> I asked on slack but I figured I’d ping the list
>> 
>> Who has a good way to ensure a serial EO creation queue when the system 
>> could be hit really fast and you must avoid duplicate entries?
>> 
>> I’m a bit surprised I don’t recall EOF style solutions for such things 
>> and maybe the Amazon RDS database has a shared connection pattern the 
>> apps can use, I didn’t see anything so I figure this is application 
>> level stuff.
>> 
>> Thoughts? Suggestions?
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>> 

Re: Single thread creation queue?

2021-11-22 Thread Aaron Rosenzweig via Webobjects-dev
Sounds like you are using Postgres?

You can use the syntax “not valid” when you create a constraint to stop the 
bleeding immediately. It will then only check for new and modified records 
allowing the bad rows to co-exist. When you get around to it, you can remove 
the duplicates. 

If it’s another database, they likely have something similar. 

> On Nov 22, 2021, at 10:18 AM, Jesse Tayler  wrote:
> 
> It’s not a compound key so much as just policy — it’s a handle for social 
> service and so there should just be one row with that value and don’t need to 
> tie into the key
> 
> I guess I can create a unique index just for that one attribute and it would 
> presumedly return an error upon save. I should re-write the EO to handle that 
> error raise and respond by returning the existing object…
> 
> I guess that is not hard to figure if that approach sounds sane.
> 
> I do have dups and I’d guess the constraint will simply fail if the database 
> has any dups in it.
> 
> I guess writing a migration to handle / remove dups is not practical so I’d 
> likely remove them by hand, then add the constraint in a migration update 
> that would gently fail until there are no more dups…
> 
> 
> 
>> On Nov 22, 2021, at 10:07 AM, Samuel Pelletier  wrote:
>> 
>> Jesse,
>> 
>> So your row have a primary key and some other unique identifier derived 
>> other attributes.
>> 
>> If the compound key is a combinaison of full attribute values, you cana a 
>> compound unique key in the database. CREATE UNIQUE INDEX ON Table (col1, 
>> col2, ..., coln)
>> 
>> If it is from partial values, the most reliable way is to add a string 
>> column with the computed key with it's unique constraint.
>> 
>> If you already have duplicate, you can add a method in the migration to 
>> resolve them before adding the constraint or do it manually...
>> 
>> Regards,
>> 
>> Samuel
>> 
>>> Le 22 nov. 2021 à 09:27, Jesse Tayler  a écrit :
>>> 
>>> It’s likely just a unique constraint perhaps.
>>> 
>>> It’s not UIDs or primary keys it’s a unique row type based on a couple 
>>> strings where there should be only one, and that one should last forever.
>>> 
>>> There’s an API where calls can come in basically at the same time and 
>>> instead of fetching first to see if the object exists, I should likely 
>>> respond to an SQL error rejecting a new row and then fetch and return that 
>>> existing object based on that error condition.
>>> 
>>> I’d suppose the database is the best place for that policy, but I don’t 
>>> think I’ve implemented constraints quite like that before so I’d need to 
>>> write some sort of Migrations for it if it’s to be reliable in all those 
>>> situations where it might encounter duplicate data…hmmm…
>>> 
>>> 
>>> 
>>> 
 On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
 
 Hi Jesse,
 
 Your question may have multiple answers, can you describe the contexts and 
 duplicate sources you fear ?
 
 Is the primary key generated by the WO app or it is external (like a GUID) 
 ?
 
 Do you have a secondary identifier that should be unique ?
 
 Anyway, you should add constraint in to the database if uniqueness is 
 required (this apply to all frameworks in all language)
 
 If you use EOF primary key generation, you should not have problems with 
 duplicate keys. If you require high throughput, using UUID primary key or 
 implementing a custom generator will help by saving round trips to the 
 database server. If you insert in batch, it will be also faster than 
 individual inserts.
 
 Regards,
 
 Samuel
 
> Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
>  a écrit :
> 
> I asked on slack but I figured I’d ping the list
> 
> Who has a good way to ensure a serial EO creation queue when the system 
> could be hit really fast and you must avoid duplicate entries?
> 
> I’m a bit surprised I don’t recall EOF style solutions for such things 
> and maybe the Amazon RDS database has a shared connection pattern the 
> apps can use, I didn’t see anything so I figure this is application level 
> stuff.
> 
> Thoughts? Suggestions?
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com
 
>>> 
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Jesse Tayler via Webobjects-dev
It’s not a compound key so much as just policy — it’s a handle for social 
service and so there should just be one row with that value and don’t need to 
tie into the key

I guess I can create a unique index just for that one attribute and it would 
presumedly return an error upon save. I should re-write the EO to handle that 
error raise and respond by returning the existing object…

I guess that is not hard to figure if that approach sounds sane.

I do have dups and I’d guess the constraint will simply fail if the database 
has any dups in it.

I guess writing a migration to handle / remove dups is not practical so I’d 
likely remove them by hand, then add the constraint in a migration update that 
would gently fail until there are no more dups…



> On Nov 22, 2021, at 10:07 AM, Samuel Pelletier  wrote:
> 
> Jesse,
> 
> So your row have a primary key and some other unique identifier derived other 
> attributes.
> 
> If the compound key is a combinaison of full attribute values, you cana a 
> compound unique key in the database. CREATE UNIQUE INDEX ON Table (col1, 
> col2, ..., coln)
> 
> If it is from partial values, the most reliable way is to add a string column 
> with the computed key with it's unique constraint.
> 
> If you already have duplicate, you can add a method in the migration to 
> resolve them before adding the constraint or do it manually...
> 
> Regards,
> 
> Samuel
> 
>> Le 22 nov. 2021 à 09:27, Jesse Tayler  a écrit :
>> 
>> It’s likely just a unique constraint perhaps.
>> 
>> It’s not UIDs or primary keys it’s a unique row type based on a couple 
>> strings where there should be only one, and that one should last forever.
>> 
>> There’s an API where calls can come in basically at the same time and 
>> instead of fetching first to see if the object exists, I should likely 
>> respond to an SQL error rejecting a new row and then fetch and return that 
>> existing object based on that error condition.
>> 
>> I’d suppose the database is the best place for that policy, but I don’t 
>> think I’ve implemented constraints quite like that before so I’d need to 
>> write some sort of Migrations for it if it’s to be reliable in all those 
>> situations where it might encounter duplicate data…hmmm…
>> 
>> 
>> 
>> 
>>> On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
>>> 
>>> Hi Jesse,
>>> 
>>> Your question may have multiple answers, can you describe the contexts and 
>>> duplicate sources you fear ?
>>> 
>>> Is the primary key generated by the WO app or it is external (like a GUID) ?
>>> 
>>> Do you have a secondary identifier that should be unique ?
>>> 
>>> Anyway, you should add constraint in to the database if uniqueness is 
>>> required (this apply to all frameworks in all language)
>>> 
>>> If you use EOF primary key generation, you should not have problems with 
>>> duplicate keys. If you require high throughput, using UUID primary key or 
>>> implementing a custom generator will help by saving round trips to the 
>>> database server. If you insert in batch, it will be also faster than 
>>> individual inserts.
>>> 
>>> Regards,
>>> 
>>> Samuel
>>> 
 Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
  a écrit :
 
 I asked on slack but I figured I’d ping the list
 
 Who has a good way to ensure a serial EO creation queue when the system 
 could be hit really fast and you must avoid duplicate entries?
 
 I’m a bit surprised I don’t recall EOF style solutions for such things and 
 maybe the Amazon RDS database has a shared connection pattern the apps can 
 use, I didn’t see anything so I figure this is application level stuff.
 
 Thoughts? Suggestions?
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
 
 This email sent to sam...@samkar.com
>>> 
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Samuel Pelletier via Webobjects-dev
Jesse,

So your row have a primary key and some other unique identifier derived other 
attributes.

If the compound key is a combinaison of full attribute values, you cana a 
compound unique key in the database. CREATE UNIQUE INDEX ON Table (col1, col2, 
..., coln)

If it is from partial values, the most reliable way is to add a string column 
with the computed key with it's unique constraint.

If you already have duplicate, you can add a method in the migration to resolve 
them before adding the constraint or do it manually...

Regards,

Samuel

> Le 22 nov. 2021 à 09:27, Jesse Tayler  a écrit :
> 
> It’s likely just a unique constraint perhaps.
> 
> It’s not UIDs or primary keys it’s a unique row type based on a couple 
> strings where there should be only one, and that one should last forever.
> 
> There’s an API where calls can come in basically at the same time and instead 
> of fetching first to see if the object exists, I should likely respond to an 
> SQL error rejecting a new row and then fetch and return that existing object 
> based on that error condition.
> 
> I’d suppose the database is the best place for that policy, but I don’t think 
> I’ve implemented constraints quite like that before so I’d need to write some 
> sort of Migrations for it if it’s to be reliable in all those situations 
> where it might encounter duplicate data…hmmm…
> 
> 
> 
> 
>> On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
>> 
>> Hi Jesse,
>> 
>> Your question may have multiple answers, can you describe the contexts and 
>> duplicate sources you fear ?
>> 
>> Is the primary key generated by the WO app or it is external (like a GUID) ?
>> 
>> Do you have a secondary identifier that should be unique ?
>> 
>> Anyway, you should add constraint in to the database if uniqueness is 
>> required (this apply to all frameworks in all language)
>> 
>> If you use EOF primary key generation, you should not have problems with 
>> duplicate keys. If you require high throughput, using UUID primary key or 
>> implementing a custom generator will help by saving round trips to the 
>> database server. If you insert in batch, it will be also faster than 
>> individual inserts.
>> 
>> Regards,
>> 
>> Samuel
>> 
>>> Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
>>>  a écrit :
>>> 
>>> I asked on slack but I figured I’d ping the list
>>> 
>>> Who has a good way to ensure a serial EO creation queue when the system 
>>> could be hit really fast and you must avoid duplicate entries?
>>> 
>>> I’m a bit surprised I don’t recall EOF style solutions for such things and 
>>> maybe the Amazon RDS database has a shared connection pattern the apps can 
>>> use, I didn’t see anything so I figure this is application level stuff.
>>> 
>>> Thoughts? Suggestions?
>>> ___
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>>> 
>>> This email sent to sam...@samkar.com
>> 
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Jesse Tayler via Webobjects-dev
It’s likely just a unique constraint perhaps.

It’s not UIDs or primary keys it’s a unique row type based on a couple strings 
where there should be only one, and that one should last forever.

There’s an API where calls can come in basically at the same time and instead 
of fetching first to see if the object exists, I should likely respond to an 
SQL error rejecting a new row and then fetch and return that existing object 
based on that error condition.

I’d suppose the database is the best place for that policy, but I don’t think 
I’ve implemented constraints quite like that before so I’d need to write some 
sort of Migrations for it if it’s to be reliable in all those situations where 
it might encounter duplicate data…hmmm…




> On Nov 22, 2021, at 8:59 AM, Samuel Pelletier  wrote:
> 
> Hi Jesse,
> 
> Your question may have multiple answers, can you describe the contexts and 
> duplicate sources you fear ?
> 
> Is the primary key generated by the WO app or it is external (like a GUID) ?
> 
> Do you have a secondary identifier that should be unique ?
> 
> Anyway, you should add constraint in to the database if uniqueness is 
> required (this apply to all frameworks in all language)
> 
> If you use EOF primary key generation, you should not have problems with 
> duplicate keys. If you require high throughput, using UUID primary key or 
> implementing a custom generator will help by saving round trips to the 
> database server. If you insert in batch, it will be also faster than 
> individual inserts.
> 
> Regards,
> 
> Samuel
> 
>> Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
>>  a écrit :
>> 
>> I asked on slack but I figured I’d ping the list
>> 
>> Who has a good way to ensure a serial EO creation queue when the system 
>> could be hit really fast and you must avoid duplicate entries?
>> 
>> I’m a bit surprised I don’t recall EOF style solutions for such things and 
>> maybe the Amazon RDS database has a shared connection pattern the apps can 
>> use, I didn’t see anything so I figure this is application level stuff.
>> 
>> Thoughts? Suggestions?
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>> 
>> This email sent to sam...@samkar.com
> 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Samuel Pelletier via Webobjects-dev
Hi Jesse,

Your question may have multiple answers, can you describe the contexts and 
duplicate sources you fear ?

Is the primary key generated by the WO app or it is external (like a GUID) ?

Do you have a secondary identifier that should be unique ?

Anyway, you should add constraint in to the database if uniqueness is required 
(this apply to all frameworks in all language)

If you use EOF primary key generation, you should not have problems with 
duplicate keys. If you require high throughput, using UUID primary key or 
implementing a custom generator will help by saving round trips to the database 
server. If you insert in batch, it will be also faster than individual inserts.

Regards,

Samuel

> Le 22 nov. 2021 à 08:34, Jesse Tayler via Webobjects-dev 
>  a écrit :
> 
> I asked on slack but I figured I’d ping the list
> 
> Who has a good way to ensure a serial EO creation queue when the system could 
> be hit really fast and you must avoid duplicate entries?
> 
> I’m a bit surprised I don’t recall EOF style solutions for such things and 
> maybe the Amazon RDS database has a shared connection pattern the apps can 
> use, I didn’t see anything so I figure this is application level stuff.
> 
> Thoughts? Suggestions?
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Single thread creation queue?

2021-11-22 Thread Aaron Rosenzweig via Webobjects-dev
Hi Jesse, 

What about SQL level “unique” and “check” constraints? 

> On Nov 22, 2021, at 8:34 AM, Jesse Tayler via Webobjects-dev 
>  wrote:
> 
> I asked on slack but I figured I’d ping the list
> 
> Who has a good way to ensure a serial EO creation queue when the system could 
> be hit really fast and you must avoid duplicate entries?
> 
> I’m a bit surprised I don’t recall EOF style solutions for such things and 
> maybe the Amazon RDS database has a shared connection pattern the apps can 
> use, I didn’t see anything so I figure this is application level stuff.
> 
> Thoughts? Suggestions?
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/aaron%40chatnbike.com
> 
> This email sent to aa...@chatnbike.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Single thread creation queue?

2021-11-22 Thread Jesse Tayler via Webobjects-dev
I asked on slack but I figured I’d ping the list

Who has a good way to ensure a serial EO creation queue when the system could 
be hit really fast and you must avoid duplicate entries?

I’m a bit surprised I don’t recall EOF style solutions for such things and 
maybe the Amazon RDS database has a shared connection pattern the apps can use, 
I didn’t see anything so I figure this is application level stuff.

Thoughts? Suggestions?
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com