Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(261)

Issue 1422041: Support DataMapper 1.0 RC

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 7 months ago by David Masover
Modified:
11 years, 2 months ago
Reviewers:
ribrdb, woodie
Visibility:
Public.

Patch Set 1 #

Total comments: 22

Patch Set 2 : Bumped DM dependency #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M dm-appengine/Rakefile View 1 chunk +1 line, -1 line 1 comment Download

Messages

Total messages: 5
David Masover
Ported dm-appengine to the DataMapper 1.0 RC. There's still work that could be done, but ...
15 years, 7 months ago (2010-05-31 07:34:01 UTC) #1
ribrdb
http://codereview.appspot.com/1422041/diff/1/2 File dm-appengine/lib/appengine_adapter.rb (right): http://codereview.appspot.com/1422041/diff/1/2#newcode71 dm-appengine/lib/appengine_adapter.rb:71: if key.nil? && keys.first.serial? 0 is special cased here ...
15 years, 7 months ago (2010-06-01 22:06:41 UTC) #2
David Masover
I'll upload another patch tonight or tomorrow. I assume I should append it to this ...
15 years, 7 months ago (2010-06-01 23:42:01 UTC) #3
ribrdb
On 2010/06/01 23:42:01, David Masover wrote: > I'll upload another patch tonight or tomorrow. I ...
15 years, 7 months ago (2010-06-03 17:38:36 UTC) #4
David Masover
15 years, 7 months ago (2010-06-04 03:35:53 UTC) #5
On 2010/06/03 17:38:36, ribrdb wrote:
> On 2010/06/01 23:42:01, David Masover wrote:
> > http://codereview.appspot.com/1422041/diff/1/2
> > File dm-appengine/lib/appengine_adapter.rb (right):
> > 
> > http://codereview.appspot.com/1422041/diff/1/2#newcode71
> > dm-appengine/lib/appengine_adapter.rb:71: if key.nil? && keys.first.serial?
> > On 2010/06/01 22:06:41, ribrdb wrote:
> > > 0 is special cased here because it's a special case in the datastore
(where
> it
> > > means to auto-assign an id).
> > 
> > That's what I thought, I'm just not clear when this would be used. But it
may
> as
> > well be kept, maybe something like:
> > 
> > if keys.first.serial? && (key.nil? || key == 0)
> 
> I think what I was trying to do was let you specify an Integer key instead of
> serial and still get auto-assigned ids.  That's probably not a good idea
though.
>  
>  
> > I realize it's not safe to specify arbitrary numbers, but that is the
behavior
> I
> > get on sqlite, where it's also not really safe. If we really want to prevent
> > people from doing this, we should raise an exception -- it seems like the
old
> > behavior was to arbitrarily ignore any user-specified integer in a serial
> field.
> 
> Yeah, raising an exception is probably the right thing to do.  

Actually, I'd vote for letting people specify arbitrary integers. It's not a
good idea, but it's also not much worse than manually specifying a value in an
autoincrement column on a normal SQL database, is it?

An example of a good reason for doing this might be migrating a bunch of data
from another app, with the current app disabled (or at least, disabled from
writes)

> No, it won't get an id until an entity is written to the datastore.  You need
to
> use the allocateIds function:
>
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/d...,
> java.lang.String, long)

Huh, alright.

> > http://codereview.appspot.com/1422041/diff/1/5
> > File dm-appengine/lib/dm-appengine/properties/key.rb (right):
> > 
> > http://codereview.appspot.com/1422041/diff/1/5#newcode43
> > dm-appengine/lib/dm-appengine/properties/key.rb:43: # TODO: is it sane to
not
> > typecast this?
> > On 2010/06/01 22:06:41, ribrdb wrote:
> > > parent.getChild(kind(property), 0) should work here.
> > 
> > Cool. Last time I tried something similar, I got an autoassigned ID --
> no-id-yet
> > is new.
> > 
> > This could resolve the @_key issue.
> 
> I don't know that it will. I'm not sure, but I would guess that the entity
gets
> a different key object when it's written and this one might keep saying the id
> is 0.  Also there's a bug in the dev_appserver datastore using keys with id 0
so
> this may not work locally until 1.3.5 is released.

I can't seem to create a new root object with an ID of 0 (without creating a new
throwaway entity first, which seems wasteful), but I can do this:

k = AppEngine::Datastore::Key.from_path 'Foo', 1
child = k.getChild 'Bar', 0
# Child currently has no-id-yet.
e = AppEngine::Datastore::Entity.new child
AppEngine::Datastore.put [e]
# Child now has an id, without even looking at the entity.

I don't know to what extent that can be relied on, but it is convenient.

> > > Maybe we should add tests for the string lengths?
> > 
> > Maybe. I think we're OK for now, though -- the scope of this is supposed to
be
> a
> > slight refactoring and upgrade to DM 1.0.
> 
> Right, I'm just worried that the refactoring might have broken the string
> lengths.

Oh, good point. We should.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b