other variables here include:

1. database backend in use, which affects "natural ordering" of data, note that 
a relational database table is unordered.   That the rows happen to come back 
"in order" is an implementation detail.

2. how primary key values are being determined

SQLAlchemy's auto-increment functionality works at the same moment as the 
INSERT so the primary key values are guaranteed inserted in order regardless of 
what decisions the ORM makes, assuming you're dealing with auto-increment.

If you set the PKs yourself, the ORM is inserting rows in the order in which 
the objects were added to the Session, unless there are inter-row dependencies 
which affect the sorting.


On Mar 6, 2012, at 12:08 PM, Amit Marcus wrote:

> yep ... i'm 100% sure
> 
> On Mar 6, 7:01 pm, Marcin Staryków <sirman...@gmail.com> wrote:
>> Are you sure it's like that? In my base's i have something like
>> id
>> 10
>> 12
>> 543
>> 765
>> etc.
>> it's because id is global that's why i can't imagine why you have other
>> numbers in the middle...
>> 
>> W dniu 6 marca 2012 17:50 użytkownik Amit Marcus <mar...@gmail.com> napisał:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> suddenly, i noticed my tables look like this:
>> 
>>> id      is_open     event_type_id       secondary_type_id       customer_id
>>> 18      1           2                   1                       1
>>> 59      1           1                   1                       1
>>> 57      1           4                   1                       2
>>> 58      1           1                   2                       1
>>> 61      1           1                   1                       1
>>> 62      1           1                   1                       1
>> 
>>> how come id 59 comes before 57 and 58?
>>> this is for the simple "SELECT * FROM
>>> `events`" (dbsession.query(Event).all())
>> 
>>> ofcourse i can use order_by id, but i was just wondering how it is
>>> even possiable.
>>> (i do not update/edit ids manually, and doing all the operations
>>> through the dbsession)
>>> this is my class
>> 
>>> class Event(DeclarativeBase):
>>>    __tablename__ = 'events'
>>>    id = Column(Integer, primary_key=True)
>>>    is_open = Column(Boolean, default=True)
>>>    event_type_id = Column(Integer, ForeignKey('event_types.id'))
>>>    secondary_type_id = Column(Integer)
>>>    reports = relationship('Report', backref='event', cascade='all,
>>> delete-orphan') # will delete reports if event is deleted
>>>    customer_id = Column(Integer, ForeignKey('customers.id')) #  no
>>> need to send it in the json cause it implicite who's the customer that
>>> gets this event
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "sqlalchemy" group.
>>> To post to this group, send email to sqlalchemy@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> sqlalchemy+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/sqlalchemy?hl=en.
>> 
>> --
>> Kind Regards
>> Marcin Starykow
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to