[sqlalchemy] Custom compiler for column is ignored when using aliases
Hi, I am currently working on adding support for Oracle to GeoAlchemy and Oracle has some methods [1] that (somehow) are only recognized when a table alias is used. The function aliased [2] seemed to work perfectly, but then I realized that the compiler extension for my custom column is not executed anymore. The compiler extension looks like this [3]: [..] class GeometryExtensionColumn(Column): pass @compiles(GeometryExtensionColumn) def compile_column(element, compiler, **kw): if kw.has_key(within_columns_clause) and kw[within_columns_clause] == True: return compiler.process(functions.wkb(element)) return element.__str__() [..] And if I make a query using the original mapped class, it works as expected: s = session.query(Spot).get(1) 2010-05-10 11:49:19,957 INFO sqlalchemy.engine.base.Engine.0x...408c SELECT SDO_UTIL.TO_WKBGEOMETRY(spots.spot_location) AS spots_spot_location, spots.spot_id AS spots_spot_id, spots.spot_height AS spots_spot_height FROM spots WHERE spots.spot_id = :param_1 2010-05-10 11:49:19,958 INFO sqlalchemy.engine.base.Engine.0x...408c {'param_1': 1} But when I create an alias and use this alias in a query, compile_column is not called anymore and in this case SDO_UTIL.TO_WKBGEOMETRY is not added to the query: spot_alias = aliased(Spot) s_alias = session.query(spot_alias).filter(spot_alias.spot_id == 1).first() 2010-05-10 11:49:36,481 INFO sqlalchemy.engine.base.Engine.0x...408c SELECT spots_1_spot_location, spots_1_spot_id, spots_1_spot_height FROM (SELECT spots_1_spot_location, spots_1_spot_id, spots_1_spot_height, ROWNUM AS ora_rn FROM (SELECT spots_1.spot_location AS spots_1_spot_location, spots_1.spot_id AS spots_1_spot_id, spots_1.spot_height AS spots_1_spot_height FROM spots spots_1 WHERE spots_1.spot_id = :spot_id_1) WHERE ROWNUM = :ROWNUM_1) WHERE ora_rn :ora_rn_1 What is going wrong? Thanks, Tobias [1]: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_objrelschema.htm#insertedID3 [2]: http://www.sqlalchemy.org/docs/ormtutorial.html#using-aliases [3]: http://bitbucket.org/geoalchemy/geoalchemy/src/c0bfcd46cb3a/geoalchemy/geometry.py#cl-121 -- 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] Re: Sql alchemy-Oracle Error
Hi This is my class definition class TaskCalendar(DeclarativeBase): __tablename__ = 'task_calendars1' cal_id = Column(Integer,Sequence('id_seq'), primary_key=True) task_id = Column(Integer, ForeignKey('tasks.task_id')) dow = Column(Integer) month = Column(Integer) day = Column(Integer) hour = Column(Integer) minute = Column(Integer) task = relation(Task, backref=backref('calendar')) This is what am trying to do tasks=DBSession.query(TaskCalendar).options(eagerload('task')) The query is as follows SELECT task_calendars1.cal_id AS task_calendars1_cal_id, task_calendars1.task_id AS task_calendars1_task_id,tasks_1.name AS tasks_1_name, tasks_1.entity_id AS tasks_1_entity_id, tasks_1.entity_name AS tasks_1_entity_name, tasks_1.context AS tasks_1_context FROM task_calendars1 LEFT OUTER JOIN tasks tasks_1 ON tasks_1.task_id = task_calendars1.task_id if i remove tasks_1.context this query works fine context column is of pickletype datatype in class and Blob in Database This is the error message: ORA-00932: inconsistent datatypes: expected NUMBER got BLOB Thankful for any suggestions -- 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] (NotSupportedError) Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECT
Hi! Using cx_oracle and SQLAlchemy 0.6 I am having troubles with Oracle objects (cx_Oracle.OBJECT) as function parameters. For example I have a function that returns an object of type cx_Oracle.OBJECT, and now I want to use that object as argument for a new function call: obj = session.scalar(func.SDO_GEOMETRY('POINT(0 0)', 4326)) 2010-05-10 16:23:57,337 INFO sqlalchemy.engine.base.Engine.0x...b82c SELECT SDO_GEOMETRY(:SDO_GEOMETRY_2, :SDO_GEOMETRY_3) AS SDO_GEOMETRY_1 FROM DUAL 2010-05-10 16:23:57,337 INFO sqlalchemy.engine.base.Engine.0x...b82c {'SDO_GEOMETRY_2': 'POINT(0 0)', 'SDO_GEOMETRY_3': 4326} session.scalar(func.SDO_UTIL.TO_WKTGEOMETRY(obj)) [..] File /../env/lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/ sqlalchemy/engine/default.py, line 277, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.NotSupportedError: (NotSupportedError) Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECT 'SELECT SDO_UTIL.TO_WKTGEOMETRY(:TO_WKTGEOMETRY_2) AS TO_WKTGEOMETRY_1 FROM DUAL' {'TO_WKTGEOMETRY_2': cx_Oracle.OBJECT object at 0x8e2f560} I tried to set a type using bindparam, but that did not help: session.scalar(func.SDO_UTIL.TO_WKTGEOMETRY(bindparam('', wkt, type_=LargeBinary))) What can I do? Thanks, Tobias -- 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] mixing metaclass with redefining the primary key of an autoloaded table
Hi, Using plain Declarative, I am able to redefine a primary key column that has been autoloaded, so that I can link it to an oracle sequence and give it a new name: Id = Column('id', Integer, Sequence('table_sq'), primary_key=True) However, if I then try to add some methods to the class using a metaclass, the foreign key relationships pointing to this column, seem to go missing. Apologies for not being able to track down the exact cause of this, but it seems to be something I am doing wrong with the combination of autloading, redefining the primary key, and adding to the class through a metaclass. The following example should work against an empty oracle schema. I get: sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child tables on relationship Customer.addresses. Specify a 'primaryjoin' expression. If this is a many-to-many relationship, 'secondaryjoin' is needed as well. http://python.pastebin.com/7V8MEfH3 from sqlalchemy import MetaData, Column, Integer, Sequence, ForeignKey, create_engine from sqlalchemy.orm import relationship, sessionmaker, scoped_session from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base engine = create_engine('oracle://fred:f...@mig01') ddls = [ drop table customer, drop table address, drop table country, drop table customer_type, create table customer_type ( id number primary key, name varchar2(10)), create table country ( id number primary key, name varchar2(10)), create table customer ( id number primary key, name varchar2(10), customer_type_id number references customer_type), create table address ( id number primary key, name varchar2(10), country_id number references country, customer_id number references customer), ] for ddl in ddls: try: print ddl, engine.execute(ddl) print 'ok' except: print 'fail' pass metadata = MetaData(bind=engine) Session = scoped_session(sessionmaker()) class RelationNameAttribute(object): def __init__(self, relationname, childclass): self.relationname = relationname self.query = Session.query(childclass) def __get__(self, obj, objtype): return getattr(getattr(obj, self.relationname), 'name') def __set__(self, obj, val): child = self.query.filter_by(name=val).one() setattr(obj, self.relationname, child) class DataMeta(DeclarativeMeta): def __init__(cls, classname, bases, dict_): classvalues = {} for name, obj in vars(cls).items(): #print name if name in ('entity', 'entity_id', 'event_id', 'attributes', '__tablename__', 'history_table', 'id_column', 'relations'): classvalues[name] = obj if 'attributes' in classvalues: # could have checked for any variable names # # Id attribute # sequence_name = classvalues['__tablename__'] + '_sq' cls.Id = Column('id', Integer, Sequence(sequence_name), primary_key=True) # # Other attributes # for aname, nname, rname, childclass in classvalues['attributes']: # # A relationship attribute # # The relationship setattr(cls, rname, relationship(childclass, uselist=False)) # The Name attribute setattr(cls, nname, RelationNameAttribute(rname, childclass)) # # Table arguments # cls.__table_args__ = {'autoload': True, 'useexisting' : True} return DeclarativeMeta.__init__(cls, classname, bases, dict_) BaseForConfig = declarative_base(metadata=metadata) BaseForData = declarative_base(metaclass=DataMeta, metadata=metadata) class Country(BaseForConfig): __tablename__ = 'country' __table_args__ = {'autoload' : True} class CustomerType(BaseForConfig): __tablename__ = 'customer_type' __table_args__ = {'autoload' : True} class Address(BaseForData): __tablename__ = 'address' history_table = 'address_history' id_column = 'addrnr' entity = 'Address' entity_id = 2 event_id = 103 attributes = [ ('CountryKey', 'CountryName', 'country', Country), ] class Customer(BaseForData): __tablename__ = 'customer' attributes = [ ('TypeKey', 'TypeName', 'type', CustomerType) ] addresses = relationship( Address, backref='customer') c = Customer() print dir(c) print c.addresses -- You received this message because you are subscribed to the Google Groups
Re: [sqlalchemy] Custom compiler for column is ignored when using aliases
creating an alias() or otherwise using the .c. collection of any selectable that's derived from another selectable (as when you say select([sometable]).c.somecolumn) means that the Column objects are actually copies of the original column objects. This copying procedure is performed by column._make_proxy(). in rb03613c840a4 I have modified this so that it uses the effective class of the object, typically self.__class__, when it constructs the new Column object. However in 0.6 it is harcdoded to ColumnClause and/or Column. So for the current release, you'd have to ensure your GeometryExtensionColumn is overriding _make_proxy() as well. I would use the _make_proxy() of Column to get its result, then change the class of the returned Column to GeometryExtensionColumn on the way out.you might want to first check that the problem goes away when using the current tip. On May 10, 2010, at 6:07 AM, Tobias wrote: Hi, I am currently working on adding support for Oracle to GeoAlchemy and Oracle has some methods [1] that (somehow) are only recognized when a table alias is used. The function aliased [2] seemed to work perfectly, but then I realized that the compiler extension for my custom column is not executed anymore. The compiler extension looks like this [3]: [..] class GeometryExtensionColumn(Column): pass @compiles(GeometryExtensionColumn) def compile_column(element, compiler, **kw): if kw.has_key(within_columns_clause) and kw[within_columns_clause] == True: return compiler.process(functions.wkb(element)) return element.__str__() [..] And if I make a query using the original mapped class, it works as expected: s = session.query(Spot).get(1) 2010-05-10 11:49:19,957 INFO sqlalchemy.engine.base.Engine.0x...408c SELECT SDO_UTIL.TO_WKBGEOMETRY(spots.spot_location) AS spots_spot_location, spots.spot_id AS spots_spot_id, spots.spot_height AS spots_spot_height FROM spots WHERE spots.spot_id = :param_1 2010-05-10 11:49:19,958 INFO sqlalchemy.engine.base.Engine.0x...408c {'param_1': 1} But when I create an alias and use this alias in a query, compile_column is not called anymore and in this case SDO_UTIL.TO_WKBGEOMETRY is not added to the query: spot_alias = aliased(Spot) s_alias = session.query(spot_alias).filter(spot_alias.spot_id == 1).first() 2010-05-10 11:49:36,481 INFO sqlalchemy.engine.base.Engine.0x...408c SELECT spots_1_spot_location, spots_1_spot_id, spots_1_spot_height FROM (SELECT spots_1_spot_location, spots_1_spot_id, spots_1_spot_height, ROWNUM AS ora_rn FROM (SELECT spots_1.spot_location AS spots_1_spot_location, spots_1.spot_id AS spots_1_spot_id, spots_1.spot_height AS spots_1_spot_height FROM spots spots_1 WHERE spots_1.spot_id = :spot_id_1) WHERE ROWNUM = :ROWNUM_1) WHERE ora_rn :ora_rn_1 What is going wrong? Thanks, Tobias [1]: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_objrelschema.htm#insertedID3 [2]: http://www.sqlalchemy.org/docs/ormtutorial.html#using-aliases [3]: http://bitbucket.org/geoalchemy/geoalchemy/src/c0bfcd46cb3a/geoalchemy/geometry.py#cl-121 -- 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] (NotSupportedError) Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECT
the first step here would be to create a cx_oracle -only application that issues your query and gets the right result back.then we can make sure sqlalchemy is passing that along in the same way. The error you are seeing is generated by cx_oracle (SQLA just wraps the NotSupportedError). What may be the issue here is that cx_oracle.OBJECT is being used at all - SQLAlchemy is not aware of this type so it appears to be some guess that cx_oracle is making about input or output parameters. On May 10, 2010, at 10:39 AM, Tobias wrote: Hi! Using cx_oracle and SQLAlchemy 0.6 I am having troubles with Oracle objects (cx_Oracle.OBJECT) as function parameters. For example I have a function that returns an object of type cx_Oracle.OBJECT, and now I want to use that object as argument for a new function call: obj = session.scalar(func.SDO_GEOMETRY('POINT(0 0)', 4326)) 2010-05-10 16:23:57,337 INFO sqlalchemy.engine.base.Engine.0x...b82c SELECT SDO_GEOMETRY(:SDO_GEOMETRY_2, :SDO_GEOMETRY_3) AS SDO_GEOMETRY_1 FROM DUAL 2010-05-10 16:23:57,337 INFO sqlalchemy.engine.base.Engine.0x...b82c {'SDO_GEOMETRY_2': 'POINT(0 0)', 'SDO_GEOMETRY_3': 4326} session.scalar(func.SDO_UTIL.TO_WKTGEOMETRY(obj)) [..] File /../env/lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/ sqlalchemy/engine/default.py, line 277, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.NotSupportedError: (NotSupportedError) Variable_TypeByValue(): unhandled data type cx_Oracle.OBJECT 'SELECT SDO_UTIL.TO_WKTGEOMETRY(:TO_WKTGEOMETRY_2) AS TO_WKTGEOMETRY_1 FROM DUAL' {'TO_WKTGEOMETRY_2': cx_Oracle.OBJECT object at 0x8e2f560} I tried to set a type using bindparam, but that did not help: session.scalar(func.SDO_UTIL.TO_WKTGEOMETRY(bindparam('', wkt, type_=LargeBinary))) What can I do? Thanks, Tobias -- 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] mixing metaclass with redefining the primary key of an autoloaded table
the clue here is that you're needing to call useexisting. this means a Table that is already reflected will be pulled from the metadata. By adding your own id column, that blows away the id that was already reflected, which is what the addresses primary key is pointing to: pdb at line 895 of properties.py (Pdb) self.target Table('address', MetaData(Engine(oracle://scott:ti...@localhost/xe)), Column('id', Integer(), table=address, primary_key=True, nullable=False, default=Sequence('address_sq', start=None, increment=None, optional=False)), Column(u'name', VARCHAR(length=10, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), table=address), Column(u'country_id', NUMBER(precision=None, scale=None, asdecimal=False), ForeignKey(u'country.id'), table=address), Column(u'customer_id', NUMBER(precision=None, scale=None, asdecimal=False), ForeignKey(u'customer.id'), table=address), schema=None) (Pdb) self.parent.mapped_table Table(u'customer', MetaData(Engine(oracle://scott:ti...@localhost/xe)), Column('id', Integer(), table=customer, primary_key=True, nullable=False, default=Sequence('customer_sq', start=None, increment=None, optional=False)), Column(u'name', VARCHAR(length=10, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), table=customer), Column(u'customer_type_id', NUMBER(precision=None, scale=None, asdecimal=False), ForeignKey(u'customer_type.id'), table=customer), schema=None) (Pdb) self.target.c.customer_id Column(u'customer_id', NUMBER(precision=None, scale=None, asdecimal=False), ForeignKey(u'customer.id'), table=address) (Pdb) self.target.c.customer_id.references(self.parent.mapped_table.c.id) False (Pdb) self.target.c.customer_id.foreign_keys OrderedSet([ForeignKey(u'customer.id')]) So the first part of the answer is to reverse the order in which you declare Customer and Address, and don't use the 'useexisting' flag - leaving it off instead ensures you are reflecting tables in their order of dependency. Then the next issue is that you're defining relationships using class objects in your metaclass - this triggers a premature mapper compilation issue and you really should be using strings to reference classes at that level (i.e. relationship (classobj.__name__)) . The RelationNameAttribute *way* oversteps its bounds by actually constructing a full blown Query() object before all classes are compiled - all of this has to occur using methods and descriptors so that nothing is asked of the mapper setup until all classes are defined. You then have to ensure your two declarative bases are sharing the same _decl_class_registry. I'd move the two bases to use one declarative base and have your metaclass check for attributes that indicate it should do its thing. Also, trying to make declarative, which is so named because it is just that, perform complex tasks implicitly is going to be difficult since it was not designed for use cases like these. On May 10, 2010, at 11:37 AM, GHZ wrote: Hi, Using plain Declarative, I am able to redefine a primary key column that has been autoloaded, so that I can link it to an oracle sequence and give it a new name: Id = Column('id', Integer, Sequence('table_sq'), primary_key=True) However, if I then try to add some methods to the class using a metaclass, the foreign key relationships pointing to this column, seem to go missing. Apologies for not being able to track down the exact cause of this, but it seems to be something I am doing wrong with the combination of autloading, redefining the primary key, and adding to the class through a metaclass. The following example should work against an empty oracle schema. I get: sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child tables on relationship Customer.addresses. Specify a 'primaryjoin' expression. If this is a many-to-many relationship, 'secondaryjoin' is needed as well. http://python.pastebin.com/7V8MEfH3 from sqlalchemy import MetaData, Column, Integer, Sequence, ForeignKey, create_engine from sqlalchemy.orm import relationship, sessionmaker, scoped_session from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base engine = create_engine('oracle://fred:f...@mig01') ddls = [ drop table customer, drop table address, drop table country, drop table customer_type, create table customer_type ( id number primary key, name varchar2(10)), create table country ( id number primary key, name varchar2(10)), create table customer ( id number primary key, name varchar2(10), customer_type_id number references customer_type), create table address ( id number primary key, name varchar2(10), country_id number references country, customer_id number
Re: [sqlalchemy] scoped_session(create_session) 0.6
Yeah, the docs are confusing on this one: http://www.sqlalchemy.org/docs/reference/orm/sessions.html?highlight=sessionmaker#sqlalchemy.orm.scoped_session Parameters: * session_factory – a callable function that produces Session instances, such as sessionmaker() or create_session(). Also I took a peak at the unittests to see if any of them passed create_session into sessionmaker, and noticed that test/orm/test_scoping.py uses it. On 05/10/2010 10:07 AM, Michael Bayer wrote: its not a bug. this is why the docs illustrate it using sessionmaker(). If there's some doc that says it just takes a callable, we should add verbiage that the configure process has additional requirements. On May 10, 2010, at 12:51 PM, David Gardner wrote: Not sure if this is a bug or not, but I am not able to call configure() on a ScopedSession that was created with create_session as it's argument. I can work around this by using sessionmaker instead, but thought I should report it as it maybe a bug. On a side note, I get the same behavior with 0.5.8 and 0.5.6 which leads me to believe this isn't a bug. --- Python 2.6.5 (r265:79063, Apr 20 2010, 19:39:53) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. from sqlalchemy.orm import scoped_session, create_session Session = scoped_session(create_session) Session.configure bound method ScopedSession.configure ofsqlalchemy.orm.scoping.ScopedSession object at 0x171d890 Session.configure() Traceback (most recent call last): File stdin, line 1, inmodule File /users/dgardner/src/pcs/branches/pylons/lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/sqlalchemy/orm/scoping.py, line 87, in configure self.session_factory.configure(**kwargs) AttributeError: 'function' object has no attribute 'configure' -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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. -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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] allow_partial_pks=False goes to database on partial pk
See this script, running 0.6.0: == from sqlalchemy import * from sqlalchemy.orm import * engine = create_engine('oracle://user:passw...@localhost:1521/xe? use_ansi=False',echo=True) metadata = MetaData() Session = sessionmaker(bind=engine) session = Session() order_table = Table(orders, metadata, Column(orderid, Unicode, primary_key=True) ) orderdetail_table = Table(orderdetails,metadata, Column(orderid, Unicode, ForeignKey('orders.orderid'), primary_key=True), Column(lineid, Integer, primary_key=True), Column(saleprice, Numeric, nullable=False) ) class Order(object): pass class OrderDetail(object): pass order_mapper = mapper(Order, order_table, properties=dict(orderdetails=relation(OrderDetail, cascade='all,delete-orphan', single_parent=True, lazy=False, backref=backref('parentorder', cascade='refresh-expire,expunge' orderdetail_mapper = mapper(OrderDetail, orderdetail_table, allow_partial_pks=False) o=Order() o.orderid = u'SALE000' # not in database line=OrderDetail() line.lineid = 1 # not in database o.orderdetails = [line] merged=session.merge(o) merged.orderdetails[0].saleprice # referencing this, with allow_partial_pks=False should not go to database == Following is the pasted output, starting with merge(): merged=session.merge(o) 2010-05-06 09:44:49,648 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT USER FROM DUAL 2010-05-06 09:44:49,652 INFO sqlalchemy.engine.base.Engine.0x...5790 {} 2010-05-06 09:44:49,656 INFO sqlalchemy.engine.base.Engine.0x...5790 BEGIN 2010-05-06 09:44:49,657 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT orders.orderid AS orders_orderid, orderdetails_1.orderid AS orderdetails_1_orderid, orderdetails_1.lineid AS orderdetails_1_lineid, orderdetails_1.saleprice AS orderdetails_1_saleprice FROM orders, orderdetails orderdetails_1 WHERE orders.orderid = :param_1 AND orders.orderid = orderdetails_1.orderid(+) 2010-05-06 09:44:49,657 INFO sqlalchemy.engine.base.Engine.0x...5790 {'param_1': u'SALE000'} merged.orderdetails[0].saleprice # referencing this, with allow_partial_pks=False should not go to database 2010-05-06 09:44:49,664 INFO sqlalchemy.engine.base.Engine.0x...5790 SELECT orderdetails.saleprice AS orderdetails_saleprice FROM orderdetails WHERE orderdetails.orderid IS NULL AND orderdetails.lineid = :param_1 2010-05-06 09:44:49,664 INFO sqlalchemy.engine.base.Engine.0x...5790 {'param_1': 1} I think this is related to the ticket 1789 in that saleprice shouldn't have been expired on a pending instance anyway. However, I wanted to report this because it seems to me there is *also* potentially something broken with allow_partial_pks=False in that, regardless of the expired status, I would have expected the query to not be issued with a pk that is partially None. Thanks in advance. -- 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: Sql alchemy-Oracle Error
This is not enough detail to provide any insight into your issue. We would require the mapping for TaskCalendar, Tasks, as well as code which inserts the offending data into the database and then issues your query, reproducing the error you are getting. On May 10, 2010, at 8:54 AM, dhanil anupurath wrote: Hi This is my class definition class TaskCalendar(DeclarativeBase): __tablename__ = 'task_calendars1' cal_id = Column(Integer,Sequence('id_seq'), primary_key=True) task_id = Column(Integer, ForeignKey('tasks.task_id')) dow = Column(Integer) month = Column(Integer) day = Column(Integer) hour = Column(Integer) minute = Column(Integer) task = relation(Task, backref=backref('calendar')) This is what am trying to do tasks=DBSession.query(TaskCalendar).options(eagerload('task')) The query is as follows SELECT task_calendars1.cal_id AS task_calendars1_cal_id, task_calendars1.task_id AS task_calendars1_task_id,tasks_1.name AS tasks_1_name, tasks_1.entity_id AS tasks_1_entity_id, tasks_1.entity_name AS tasks_1_entity_name, tasks_1.context AS tasks_1_context FROM task_calendars1 LEFT OUTER JOIN tasks tasks_1 ON tasks_1.task_id = task_calendars1.task_id if i remove tasks_1.context this query works fine context column is of pickletype datatype in class and Blob in Database This is the error message: ORA-00932: inconsistent datatypes: expected NUMBER got BLOB Thankful for any suggestions -- 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.