[sqlalchemy] rowcount not populated?

2010-10-26 Thread Wichert Akkerman
On an environment using SQLAlchemy 0.6.5 and psycopg 2.2.2 I run the 
following code:


  session.execute(Article.__table__.update()
  .where(Article.retailer_id==self.retailer_id)
  .where(Article.publish_end=datetime.date.today())
  .values(publish_end=yesterday()))

this returns a ResultProxy object, which always has rowcount set to 0:

(Pdb) p result.supports_sane_rowcount()
True
(Pdb) p result.rowcount
0

doing the same thing manually in a psql session shows that 858 rows are 
updated by this command. Is my expectation that result.rowcount should 
be set here incorrect?


Wichert.

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



[sqlalchemy] set a field to the result of a query automatically

2010-10-26 Thread Adam Medveczky
Hi!

I have a localization table, with a string_id, locale_id which make a
composite key (and of course the localized string)

I'd like to refer to it from various tables, based on a local field
which resembles 'string_id'.

If I wanted to do this with only one table referring to it, it would
be a simple one-to-many association, but now I'd have to put a foreign
key of each referral table (having always one filled), which may be a
solution, but certainly not the best. Making an intermediate associate
table suffers the same drawback, still more keys are needed.

Basically, I would like to have a field in these classes which have an
array of results from the localization table if I access it.

I'm using declarative, this probably matters.

Any ideas? Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



[sqlalchemy] importing BigInteger

2010-10-26 Thread blahsphemer
I am unable to import the type BigInteger in my code, but integer,
string get imported flawlessly
I tried both:
from sqlalchemy import BigInteger
(and)
from sqlalchemy.types import BigInteger

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



Re: [sqlalchemy] rowcount not populated?

2010-10-26 Thread Michael Bayer
the result should have a rowcount, yes.   we have a lot of tests for rowcount 
which pass so would need something very specific to test here.



On Oct 26, 2010, at 7:15 AM, Wichert Akkerman wrote:

 On an environment using SQLAlchemy 0.6.5 and psycopg 2.2.2 I run the 
 following code:
 
  session.execute(Article.__table__.update()
  .where(Article.retailer_id==self.retailer_id)
  .where(Article.publish_end=datetime.date.today())
  .values(publish_end=yesterday()))
 
 this returns a ResultProxy object, which always has rowcount set to 0:
 
 (Pdb) p result.supports_sane_rowcount()
 True
 (Pdb) p result.rowcount
 0
 
 doing the same thing manually in a psql session shows that 858 rows are 
 updated by this command. Is my expectation that result.rowcount should be set 
 here incorrect?
 
 Wichert.
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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 sqlalch...@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.



Re: [sqlalchemy] set a field to the result of a query automatically

2010-10-26 Thread Michael Bayer

On Oct 26, 2010, at 7:21 AM, Adam Medveczky wrote:

 Hi!
 
 I have a localization table, with a string_id, locale_id which make a
 composite key (and of course the localized string)
 
 I'd like to refer to it from various tables, based on a local field
 which resembles 'string_id'.
 
 If I wanted to do this with only one table referring to it, it would
 be a simple one-to-many association, but now I'd have to put a foreign
 key of each referral table (having always one filled), which may be a
 solution, but certainly not the best.

If this were simple many-to-one, i.e. A.string_id (fk) - 
localization.string_id, B.string_id (fk) - localization.string_id, etc.  , 
that's very simple, but I guess you're looking for a collection.


 Making an intermediate associate
 table suffers the same drawback, still more keys are needed.

so this sounds more like yes you're looking for a collection:

A - a_to_locale.string_id (fk) - localization.string_id, B - 
b_to_locale.string_id (fk) - localization.string_id .This is actually the 
solution I recommend in my old blog post about polymorphic associations 
http://techspot.zzzeek.org/?p=13 .

There's no real drawback to having lots of foreign keys.   Relational 
structures can be verbose but thats why tools like SQLAlchemy were created.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



Re: [sqlalchemy] importing BigInteger

2010-10-26 Thread Michael Bayer
perhaps an old SQLAlchemy version, cannot reproduce:

 from sqlalchemy import __version__
 __version__
'0.6.5'
 from sqlalchemy import BigInteger
 BigInteger
class 'sqlalchemy.types.BigInteger'
 



On Oct 26, 2010, at 9:15 AM, blahsphemer wrote:

 I am unable to import the type BigInteger in my code, but integer,
 string get imported flawlessly
 I tried both:
 from sqlalchemy import BigInteger
 (and)
 from sqlalchemy.types import BigInteger
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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 sqlalch...@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.



Re: [sqlalchemy] importing BigInteger

2010-10-26 Thread Eknath Venkataramani
On Tue, Oct 26, 2010 at 10:20 AM, Michael Bayer mike...@zzzcomputing.comwrote:

 perhaps an old SQLAlchemy version, cannot reproduce:

 That's weird. I have the same version. I downloaded 30 minutes before I
faced the problem. I even checked the version


-- 
Eknath Venkataramani

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



Re: [sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-26 Thread Lenza McElrath
Thanks for the quick response Michael.

I do not know why all references to the object are lost.  Adding the asserts
you suggested shows that the object is in the session and in the dirty list
as expected.

I have been able to reproduce the issue with a simple test case.  I have
untangled it from my infrastructure as much as possible, but you will have
to provide your own sessionmaker and BaseModel.  Please let me know if you
are able to reproduce with this: http://pastebin.com/pC45S59E

Interestingly, if I run the test on an existing row (as opposed to creating
the row in the test) the test passes.

  -Lenza

On Mon, Oct 25, 2010 at 10:33 AM, Michael Bayer mike...@zzzcomputing.comwrote:


 On Oct 25, 2010, at 1:07 PM, Lenza McElrath wrote:

 I am running into a issue where it looks like SQLAlchemy is not performing
 the proper DB update when committing a session after modifying an object.
 This happens only when all references to the updated object are lost, and I
 update a mutable attribute BEFORE updating another attribute.  It seems as
 if MutableAttrInstanceState.__resurrect is not properly resurrecting the
 object state.

 I have code that basically looks like this:

 def update_my_model(session, my_model_id):
 my_model = session.query(MyModel, id=my_model_id).one()
 my_model.mutable_attribute.mutate()
 my_model.normal_attribute = 42
 return my_model

 session = self.logic.session_maker()
 update_my_model(session, my_model_id)
 session.commit()

 The above code does issues the SQL to update mutable_attribute, but not
 normal_attribute.  Everything works if I move the mutable_attribute change
 to after the normal_attribute change, remove it completely, or assign the
 return value of the update_my_model call to a variable.

 I have been able to determine that in that case that fails (and only in
 that case) MutableAttrInstanceState._cleanup is being called as
 update_my_model returns.  However, during the session.commit(), the call
 to self.manager.new_instance(state=self) in
 MutableAttrInstanceState.__resurrect is not returning an object that has
 normal_attribute set.  From what I can tell the MutableAttrInstanceState
 instance should know about the update to normal_attribute (
 InstanceState.modified_event is being called when it is set).  But I'm not
 sure of the inner-workings of MutableAttrInstanceState,so I haven't been
 able to confirm this.


 What is not explained here is how the reference would be lost in the first
 place.   The change to my_model.normal_attribute would place the object in
 the session's dirty list which results in a strong reference being created
 from the state to the object, which in turn is strongly referenced by the
 Session's identity map.



 My mutable_attribute is rather complex, so it is entirely possible that it
 is behaving badly in some why.  However, this seems like a strange failure
 mode for an issue with that attribute?  Anyone have ideas on what is going
 on here, or what my next steps should be to track it down?  If any
 information I have not provided would be helpful, please let me know.


 oh well definitely, try to create a simple test case.   For example, if I
 were to just take code like the above with a generic model, does that
 reproduce the issue ?If you think something about your mutable attribute
 is at fault, try replacing it with a plain dictionary and change a value
 within.   I can't really imagine how anything regarding your mutable type
 could be involved unless it reaches out and modifies the environment
 containing my_model somehow.

 If just the code above, I'd do things like:

 def update_my_model(session, my_model_id):
 my_model = session.query(MyModel, id=my_model_id).one()
 my_model.mutable_attribute.mutate()
 assert my_model in session
 my_model.normal_attribute = 42
 assert my_model in session.dirty
 return my_model





  --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.comsqlalchemy%2bunsubscr...@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 sqlalch...@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.



Re: [sqlalchemy] Re: SQLAlchemy not updating all expected columns after mutable attribute modification

2010-10-26 Thread Michael Bayer
thanks, this is a simple issue that appears to be throughout the 0.6 series 
only, resolved in r26f423a667ca which you can get at 
http://hg.sqlalchemy.org/sqlalchemy/archive/26f423a667ca.tar.gz .


On Oct 26, 2010, at 2:41 PM, Lenza McElrath wrote:

 Thanks for the quick response Michael.
 
 I do not know why all references to the object are lost.  Adding the asserts 
 you suggested shows that the object is in the session and in the dirty list 
 as expected. 
 
 I have been able to reproduce the issue with a simple test case.  I have 
 untangled it from my infrastructure as much as possible, but you will have to 
 provide your own sessionmaker and BaseModel.  Please let me know if you are 
 able to reproduce with this: http://pastebin.com/pC45S59E
 
 Interestingly, if I run the test on an existing row (as opposed to creating 
 the row in the test) the test passes.
 
   -Lenza
 
 On Mon, Oct 25, 2010 at 10:33 AM, Michael Bayer mike...@zzzcomputing.com 
 wrote:
 
 On Oct 25, 2010, at 1:07 PM, Lenza McElrath wrote:
 
 I am running into a issue where it looks like SQLAlchemy is not performing 
 the proper DB update when committing a session after modifying an object.  
 This happens only when all references to the updated object are lost, and I 
 update a mutable attribute BEFORE updating another attribute.  It seems as 
 if MutableAttrInstanceState.__resurrect is not properly resurrecting the 
 object state.
 
 I have code that basically looks like this:
 
 def update_my_model(session, my_model_id):
 my_model = session.query(MyModel, id=my_model_id).one()
 my_model.mutable_attribute.mutate()
 my_model.normal_attribute = 42
 return my_model
 
 session = self.logic.session_maker()
 update_my_model(session, my_model_id)
 session.commit()
 
 The above code does issues the SQL to update mutable_attribute, but not 
 normal_attribute.  Everything works if I move the mutable_attribute change 
 to after the normal_attribute change, remove it completely, or assign the 
 return value of the update_my_model call to a variable.
 
 I have been able to determine that in that case that fails (and only in that 
 case) MutableAttrInstanceState._cleanup is being called as update_my_model 
 returns.  However, during the session.commit(), the call to 
 self.manager.new_instance(state=self) in 
 MutableAttrInstanceState.__resurrect is not returning an object that has 
 normal_attribute set.  From what I can tell the MutableAttrInstanceState 
 instance should know about the update to normal_attribute 
 (InstanceState.modified_event is being called when it is set).  But I'm not 
 sure of the inner-workings of MutableAttrInstanceState,so I haven't been 
 able to confirm this.
 
 What is not explained here is how the reference would be lost in the first 
 place.   The change to my_model.normal_attribute would place the object in 
 the session's dirty list which results in a strong reference being created 
 from the state to the object, which in turn is strongly referenced by the 
 Session's identity map.  
 
 
 
 My mutable_attribute is rather complex, so it is entirely possible that it 
 is behaving badly in some why.  However, this seems like a strange failure 
 mode for an issue with that attribute?  Anyone have ideas on what is going 
 on here, or what my next steps should be to track it down?  If any 
 information I have not provided would be helpful, please let me know.
 
 oh well definitely, try to create a simple test case.   For example, if I 
 were to just take code like the above with a generic model, does that 
 reproduce the issue ?If you think something about your mutable attribute 
 is at fault, try replacing it with a plain dictionary and change a value 
 within.   I can't really imagine how anything regarding your mutable type 
 could be involved unless it reaches out and modifies the environment 
 containing my_model somehow.
 
 If just the code above, I'd do things like:
 
 def update_my_model(session, my_model_id):
 my_model = session.query(MyModel, id=my_model_id).one()
 my_model.mutable_attribute.mutate()
 assert my_model in session
 my_model.normal_attribute = 42
 assert my_model in session.dirty
 return my_model
 
 
 
 
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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 sqlalch...@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 

[sqlalchemy] Containers/collections with SQLAlchemy

2010-10-26 Thread Hector Blanco
Hi group!

I am trying to migrate my application from ZopeDB to MySql. I am using
sqlalchemy under megrok.rdb.

I have a class which inherits from list() and has a few extra methods.
Reading the chapter about custom collections in sqlalchemy
(http://www.sqlalchemy.org/docs/orm/collections.html#custom-collection-implementations),
I thought that I'd be great having that class as a custom collection
(extending from list() but simulating a set(), where the items can't
be repeated)

That class that extends from list, acts as a container of other
classes (mmm... yeah, as all the collections do... pretty obvious). It
is used (as an attribute) in other classes as well:

class MyEntry(object):
def __init__(self):
self.field1 = “field1”
self.field2 = “field2”


class MyContainer(list):
__emulates__ = set
def __init__(self):
super(MyContainer,self).__init__()

def add(self, myEntry):
if isinstance(myEntry, MyEntry):
if not(myEntry in self):
super(MyContainer, self).append(myEntry)

def getByField1(self, field1):
for element in self:
if element.field1 == field1:
return element
return None
#   [ ...
#   more useful methods,
#   overloading to make the list behave like a set,
#   yada yada yada
#   ...]


class MyClass(object):
def __init__(self):
self.container1 = MyContainer()
self.container2 = MyContainer()
self.anotherField = “hello world”
def getContainer1():
return self.container1
def getContainer2():
return self.container2

I see clearly the MyEntry and (more or less clearly) MyClass
classes modeled in tables.
I also see clearly the intermediate table for MyContainer:

my_containers_table = Table(
my_containers_table,
metadata,
Column(id, Integer,  primary_key=True),
Column(my_entry_id, Integer, ForeignKey(my_entries_table.id))
)

So, in the MyClass class, each of MyContainer() instances can have an
id and when someone wants to retrieve the MyEntry() elements that are
in container1 (to say so), the my_containers_table can be used as a
middle table to get said MyEntries.

but I don't know how to link the MyContainer(list) object with
my_containers_table (and from there with MyClass) :-(

I'm not even sure whether MyClass.container1 and MyClass.container2
should be ForeignKeys or Relations.

How can I establish the relationship between MyClass.container1 or
MyClass.container2 with my_containers_table?

On one hand, I want MyClass.container1 and MyClass.container2 to be
foreign keys, but on the other, I want them to be instances of
MyContainer(list)... And that's where I start banging my head on the
wall :-)

In my mind (preferably before banging it against the wall) I see this schema:

 +---Entry+
 | id = 1|
 |field1   | +container1---+
 |field2   |  |id = 10|
 +-+ |  foreign[0] = 1   |
|  foreign[1] = 2   |+- myClass +
 +---Entry---++--+   |  id = 101 |
 |id = 2 | |
anotherField|
 |field1   | |
container1 = 10  |
 |field2   | +container2---+| container2 = 20  |
 +-+ |  id = 20  | +-+
|  foreign[0] = 3   |
 +---Entry---++-+
 |id = 3|
 |field1  |
 |field2  |
 ++

[I hope the Ascii thing is properly displayed]

When I want to get all what is in myClass.container1, the system
should go to my_containers_table with the myClass.container1's id (10)
and retrieve all the MyEntries (id=1 and id=2 in the example above)
pointed by the ForeingKey of my_containers_table. That's what I want
the system to do. But that's not what it's doing.

Any tip will be deeply appreciated. Links to manuals,
documentations... whatever (I'm a total newbie in sqlmyalchemy)

Thank you again!

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



RE: [sqlalchemy] Containers/collections with SQLAlchemy

2010-10-26 Thread Jeff Peterson
http://grok.zope.org/documentation/how-to/orm-using-megrok.rdb-and-sqlalchemy

http://www.sqlalchemy.org/docs/

--
Jeffrey D Peterson
Webmaster
Crary Industries, Inc.
237 12th St NW
West Fargo, ND 58078
P: 701-499-5928
E: jeff.peter...@crary.com

 -Original Message-
 From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com]
 On Behalf Of Hector Blanco
 Sent: Tuesday, October 26, 2010 5:40 PM
 To: sqlalchemy@googlegroups.com
 Subject: [sqlalchemy] Containers/collections with SQLAlchemy
 
 Hi group!
 
 I am trying to migrate my application from ZopeDB to MySql. I am using
 sqlalchemy under megrok.rdb.
 
 I have a class which inherits from list() and has a few extra methods.
 Reading the chapter about custom collections in sqlalchemy
 (http://www.sqlalchemy.org/docs/orm/collections.html#custom-collection-
 implementations),
 I thought that I'd be great having that class as a custom collection
 (extending from list() but simulating a set(), where the items can't
 be repeated)
 
 That class that extends from list, acts as a container of other
 classes (mmm... yeah, as all the collections do... pretty obvious). It
 is used (as an attribute) in other classes as well:
 
 class MyEntry(object):
   def __init__(self):
   self.field1 = field1
   self.field2 = field2
 
 
 class MyContainer(list):
   __emulates__ = set
   def __init__(self):
   super(MyContainer,self).__init__()
 
   def add(self, myEntry):
   if isinstance(myEntry, MyEntry):
   if not(myEntry in self):
   super(MyContainer, self).append(myEntry)
 
   def getByField1(self, field1):
   for element in self:
   if element.field1 == field1:
   return element
   return None
 # [ ...
 # more useful methods,
 # overloading to make the list behave like a set,
 # yada yada yada
 # ...]
 
 
 class MyClass(object):
   def __init__(self):
   self.container1 = MyContainer()
   self.container2 = MyContainer()
   self.anotherField = hello world
   def getContainer1():
   return self.container1
   def getContainer2():
   return self.container2
 
 I see clearly the MyEntry and (more or less clearly) MyClass
 classes modeled in tables.
 I also see clearly the intermediate table for MyContainer:
 
 my_containers_table = Table(
   my_containers_table,
   metadata,
   Column(id, Integer,  primary_key=True),
   Column(my_entry_id, Integer, ForeignKey(my_entries_table.id))
 )
 
 So, in the MyClass class, each of MyContainer() instances can have an
 id and when someone wants to retrieve the MyEntry() elements that are
 in container1 (to say so), the my_containers_table can be used as a
 middle table to get said MyEntries.
 
 but I don't know how to link the MyContainer(list) object with
 my_containers_table (and from there with MyClass) :-(
 
 I'm not even sure whether MyClass.container1 and MyClass.container2
 should be ForeignKeys or Relations.
 
 How can I establish the relationship between MyClass.container1 or
 MyClass.container2 with my_containers_table?
 
 On one hand, I want MyClass.container1 and MyClass.container2 to be
 foreign keys, but on the other, I want them to be instances of
 MyContainer(list)... And that's where I start banging my head on the
 wall :-)
 
 In my mind (preferably before banging it against the wall) I see this
 schema:
 
  +---Entry+
  | id = 1|
  |field1   | +container1---+
  |field2   |  |id = 10|
  +-+ |  foreign[0] = 1   |
 |  foreign[1] = 2   |+- myClass
 +
  +---Entry---++--+   |  id = 101
 |
  |id = 2 | |
 anotherField|
  |field1   | |
 container1 = 10  |
  |field2   | +container2---+| container2 = 20  |
  +-+ |  id = 20  | +---
 --+
 |  foreign[0] = 3   |
  +---Entry---++-+
  |id = 3|
  |field1  |
  |field2  |
  ++
 
 [I hope the Ascii thing is properly displayed]
 
 When I want to get all what is in myClass.container1, the system
 should go to my_containers_table with the myClass.container1's id (10)
 and retrieve all the MyEntries (id=1 and id=2 in the example above)
 pointed by the ForeingKey of my_containers_table. That's what I want
 the system to do. But that's not what it's doing.
 
 Any tip will be deeply appreciated. Links to manuals,
 documentations... whatever (I'm a total newbie in sqlmyalchemy)
 
 Thank you again!
 
 --
 You 

[sqlalchemy] IS NULL filter, non-NULL row returned

2010-10-26 Thread Diana Clarke
Any ideas why I'm getting one row back with an id of 5 when I filtered
by id IS NULL?

[SQLAlchemy-0.6.4, MySQL 5, MyISAM]

sqlalchemy.engine.base.Engine.0x...eb2c: INFO: SELECT user.id AS
user_id, user.username AS user_username, user.level AS user_level
FROM user
WHERE user.level = %s AND user.id IS NULL

sqlalchemy.engine.base.Engine.0x...eb2c: INFO: (1,)

sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Col ('user_id',
'user_username', 'user_level')

sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Row (5L, u'jane', 1)

Thanks,

--diana

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



Re: [sqlalchemy] IS NULL filter, non-NULL row returned

2010-10-26 Thread Michael Bayer
yeah you'd have to search around MySQL's bugtracker for that one, I've seen it 
before, the only record I can find at the moment is #4 here:

http://sql-info.de/mysql/gotchas.html#1_1




On Oct 26, 2010, at 11:16 PM, Diana Clarke wrote:

 Any ideas why I'm getting one row back with an id of 5 when I filtered
 by id IS NULL?
 
[SQLAlchemy-0.6.4, MySQL 5, MyISAM]
 
 sqlalchemy.engine.base.Engine.0x...eb2c: INFO: SELECT user.id AS
 user_id, user.username AS user_username, user.level AS user_level
 FROM user
 WHERE user.level = %s AND user.id IS NULL
 
 sqlalchemy.engine.base.Engine.0x...eb2c: INFO: (1,)
 
 sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Col ('user_id',
 'user_username', 'user_level')
 
 sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Row (5L, u'jane', 1)
 
 Thanks,
 
 --diana
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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 sqlalch...@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.



Re: [sqlalchemy] IS NULL filter, non-NULL row returned

2010-10-26 Thread Diana Clarke
Wow, I want to unlearn this.


For the benefit of some ODBC applications, the following query can be
used to find a newly inserted row: ... SELECT * FROM tbl_name WHERE
auto IS NULL;

All further executions of the same statement provide the expected result


Thanks, Michael!

--diana

On Tue, Oct 26, 2010 at 11:27 PM, Michael Bayer
mike...@zzzcomputing.com wrote:
 yeah you'd have to search around MySQL's bugtracker for that one, I've seen 
 it before, the only record I can find at the moment is #4 here:

 http://sql-info.de/mysql/gotchas.html#1_1




 On Oct 26, 2010, at 11:16 PM, Diana Clarke wrote:

 Any ideas why I'm getting one row back with an id of 5 when I filtered
 by id IS NULL?

    [SQLAlchemy-0.6.4, MySQL 5, MyISAM]

 sqlalchemy.engine.base.Engine.0x...eb2c: INFO: SELECT user.id AS
 user_id, user.username AS user_username, user.level AS user_level
 FROM user
 WHERE user.level = %s AND user.id IS NULL

 sqlalchemy.engine.base.Engine.0x...eb2c: INFO: (1,)

 sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Col ('user_id',
 'user_username', 'user_level')

 sqlalchemy.engine.base.Engine.0x...eb2c: DEBUG: Row (5L, u'jane', 1)

 Thanks,

 --diana

 --
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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 sqlalch...@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 sqlalch...@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.