Id overwriting

58 views
Skip to first unread message

Sorin Carbunaru

unread,
Mar 21, 2013, 6:56:04 AM3/21/13
to ged...@googlegroups.com
I am trying to overwrite the automatically assigned id with a value entered in a form. The problem is that when I check the stored value, it is not mine, but still the generated one. My id is declared in the model, I extract the value from an inputTag with name = "id" and then I try to store it in the controller like this -> id: params.id. Am I doing something wrong?

Node.js 0.8.20
Geddy 0.7.13
Win 8 64 bit

Miguel Madero

unread,
Mar 21, 2013, 1:10:06 PM3/21/13
to ged...@googlegroups.com

Thats a bug. I have a halfdone fix for it, but I'm not happy to push it to master as it's. I'll be away for a week so ill try to push the branch later tonight.

Which adapter are you using?

--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sorin Carbunaru

unread,
Mar 21, 2013, 2:05:31 PM3/21/13
to ged...@googlegroups.com
I'm using the in-memory option.

Miguel Madero

unread,
Mar 22, 2013, 3:34:57 PM3/22/13
to ged...@googlegroups.com
Hi Sorin, 

There's a new model branch called customIds it fixes this problem for the memory adapter and adds tests to ensure this behavior is consistent on all the other adapters. At the moment the these tests are broken for the other adapters. You can try this by updating the new adapter code. I'm short on time at the moment since I'm moving, but I'll have a look at the other adapters next week once I settle unless someone beats me to it. @logomezma, @ondrej or @ben maybe you guys can jump on this? 



Miguel


On Thu, Mar 21, 2013 at 12:05 PM, Sorin Carbunaru <sorinca...@yahoo.com> wrote:
I'm using the in-memory option.

--

Matthew Eernisse

unread,
Mar 22, 2013, 3:44:08 PM3/22/13
to ged...@googlegroups.com
Noticed when building a Geddy app the other week for our Hack Day at Yammer that the generated CRUD scaffolds do the id assignment inline in the `create` method. I'm not sure what the intention was here, but unless you're doing an override, this should be the job of the model auto-assign.

Ben Ng

unread,
Mar 22, 2013, 4:00:24 PM3/22/13
to ged...@googlegroups.com
I've been wondering the same thing myself when looking at the scaffolds. Usually ID assignment is the job of the model.

Does this mean I can lose the `id:geddy.string.uuid(10)` in my `create` methods and things will still work?

Matthew Eernisse

unread,
Mar 22, 2013, 4:14:17 PM3/22/13
to ged...@googlegroups.com
Yes. This should be the purview of the model code (or the DB itself if you're using autoIncrement), but should be overrideable.

$ ack uuid lib
lib/adapters/base_adapter.js
31:    data.id = utils.string.uuid()
lib/adapters/memory/index.js
200:      var id = utils.string.uuid();
lib/adapters/mongo/index.js
286:        id = utils.string.uuid();
lib/adapters/riak/index.js
314:        id = utils.string.uuid();
lib/adapters/sql/base.js
29:      item.id = utils.string.uuid();

Miguel Madero

unread,
Mar 22, 2013, 4:14:07 PM3/22/13
to ged...@googlegroups.com
The model does this. I thought I removed this ages ago from the templates, but there was probably a merge problem. 



Miguel

Miguel Madero

unread,
Mar 22, 2013, 4:14:53 PM3/22/13
to ged...@googlegroups.com
We should change the templates AND fix to allow the overrides only when/if needed 


Miguel

Matthew Eernisse

unread,
Mar 22, 2013, 4:18:52 PM3/22/13
to ged...@googlegroups.com
Yes, looks like there was a merge conflict. I had some problems in templates when I merged the old release branch back in to master. I hadn't been good about keeping master up to date. I'm doing much better now with v0.7, merging back to master after every NPM publish.

Sorin Carbunaru

unread,
Mar 25, 2013, 1:01:44 PM3/25/13
to ged...@googlegroups.com
Hello again!

So, do I have to wait for some changes in Geddy so that the overwriting will work just by extracting the value from the form and then id: params.id ?

Miguel Madero

unread,
Mar 25, 2013, 1:06:21 PM3/25/13
to ged...@googlegroups.com
Hi Sorin, 

This is only fixed on git and only for the memory adapter. We won't update geddy until this is working for all the other adapters as well. I'm a bit short on time this week, but I'll expect to get to this next weekend (unless of course someone beats me to it). 


Miguel


On Mon, Mar 25, 2013 at 11:01 AM, Sorin Carbunaru <sorinca...@yahoo.com> wrote:
Hello again!

So, do I have to wait for some changes in Geddy so that the overwriting will work just by extracting the value from the form and then id: params.id ?

--

Matthew Eernisse

unread,
Mar 25, 2013, 11:42:13 PM3/25/13
to ged...@googlegroups.com
I should add that I've removed that from the `create` method -- the change is in both the release and master.

Miguel



Miguel


To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+unsubscribe@googlegroups.com.

Matthew Eernisse

unread,
Mar 25, 2013, 11:51:07 PM3/25/13
to ged...@googlegroups.com
A possible workaround for this would be to save your instance so it saves correctly with an auto-generated id, then do an update with your new id property.

Sorin Carbunaru

unread,
Apr 15, 2013, 8:52:35 AM4/15/13
to ged...@googlegroups.com
Hello again!

What is the status of this issue? 

Miguel Madero

unread,
Apr 15, 2013, 1:30:42 PM4/15/13
to ged...@googlegroups.com
Hi Sorin, 

This is fixed only for the memory adapter in the branch customIds in model. Have you had a chance to test it? 

Let me know if that's still an issue. In the meantime, I'll have a look at the other adapters. 


Thanks,
Miguel


On Mon, Apr 15, 2013 at 5:52 AM, Sorin Carbunaru <sorinca...@yahoo.com> wrote:
Hello again!

What is the status of this issue? 

--

Sorin Carbunaru

unread,
Apr 15, 2013, 2:57:24 PM4/15/13
to ged...@googlegroups.com
Well, no. I used Geddy for a project at the university where I went as an exchange student. I came home 3 weeks ago, so I stopped working at that project. 

Now, about the overwriting. Do I have to do something special to make it work? I've reinstalled Geddy today and tried to save an entry in memory with an integer ID, but when I've checked the value, it was that annoying (for me) hexadecimal string.

Miguel Madero

unread,
Apr 26, 2013, 4:42:42 PM4/26/13
to ged...@googlegroups.com
This is fixed now on master for all the DBs


Miguel


On Mon, Apr 15, 2013 at 11:57 AM, Sorin Carbunaru <sorinca...@yahoo.com> wrote:
Well, no. I used Geddy for a project at the university where I went as an exchange student. I came home 3 weeks ago, so I stopped working at that project. 

Now, about the overwriting. Do I have to do something special to make it work? I've reinstalled Geddy today and tried to save an entry in memory with an integer ID, but when I've checked the value, it was that annoying (for me) hexadecimal string.

--

Matthew Eernisse

unread,
Apr 27, 2013, 1:21:28 AM4/27/13
to ged...@googlegroups.com
Awesome work on this!

Miguel Madero

unread,
Apr 27, 2013, 1:40:24 AM4/27/13
to ged...@googlegroups.com
Thanks. It was a quick change at the end, just didn't have a chance to get to it earlier and I didn't have mongo on my day to day machine. 

BTW, I noticed you renamed to riak tests to ignore them. Why was that? (I can't test it here). 

Miguel
Reply all
Reply to author
Forward
0 new messages