bug with DatabaseRow #hasOldVersion

15 views
Skip to first unread message

Micael Alastor

unread,
Jun 19, 2012, 7:20:44 AM6/19/12
to glorp...@googlegroups.com
looks like:

1. create 2 objects with ManyToMany relationship (like User with collection of #groups and Group with collection of #users).

user:= User new.
group := Group new..

2.  register one of them

session inUnitOfWorkDo:[session register: group]. 

3. create relationship

user groups add: group.
group users add: user.

4. register another one

session inUnitOfWorkDo:[session register: user].

5. aDatabaseRow hasOldVersion = true 

6. glorp tries to update instead of insert

7. PROFIT

Micael Alastor

unread,
Jun 19, 2012, 7:26:25 AM6/19/12
to glorp...@googlegroups.com
Of cours, we can do:

session inUnitOfWorkDo:[session register: user; register: group. user groups add: group. group users add: user]

and it will be OK, but bug is so ugly =(

Alan Knight

unread,
Jun 19, 2012, 11:26:15 AM6/19/12
to glorp...@googlegroups.com
I think this is probably related to primary keys, or lack of same, on the link table. I think it's that you should have both link table fields as a primary key, though I don't have an example handy to check.

Micael Alastor wrote:
--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/1igt4L-awgMJ.
To post to this group, send email to glorp...@googlegroups.com.
To unsubscribe from this group, send email to glorp-group...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.

Micael Alastor

unread,
Jun 19, 2012, 11:47:09 AM6/19/12
to glorp...@googlegroups.com
tableForAOSUSERS_AOSSECURITYGROUPS: aTable 
| user group |
user := aTable createFieldNamed: 'USERID' type: (platform varchar: 36).
user bePrimaryKey.
aTable addForeignKeyFrom: user
to: ((self tableNamed: 'AOSUSERS') fieldNamed: 'ID').
group := aTable createFieldNamed: 'GROUPID' type: (platform varchar: 36).
group bePrimaryKey.
aTable addForeignKeyFrom: group
to: ((self tableNamed: 'AOSUSERS') fieldNamed: 'ID')

It's the description of the link table. There is an easy workaround, so.. 
To unsubscribe from this group, send email to glorp-group+unsubscribe@googlegroups.com.

Alan Knight

unread,
Jun 19, 2012, 1:34:30 PM6/19/12
to glorp...@googlegroups.com
Hmm. Very peculiar, though. There's no way it should make any difference what order you add things to the unit of work.

To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/pjWySSXj2nwJ.

To post to this group, send email to glorp...@googlegroups.com.
To unsubscribe from this group, send email to glorp-group...@googlegroups.com.

Wallen, David

unread,
Jun 19, 2012, 1:52:28 PM6/19/12
to glorp...@googlegroups.com

I wonder if it would help if your primary keys were integers instead? Your existing design should work okay, but it would be useful to know if that change has an effect.

To unsubscribe from this group, send email to glorp-group...@googlegroups.com.


For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.

--

You received this message because you are subscribed to the Google Groups "glorp-group" group.

To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/pjWySSXj2nwJ.


To post to this group, send email to glorp...@googlegroups.com.

To unsubscribe from this group, send email to glorp-group...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages