Re: [sqlalchemy] ORM and table with no primary key

2016-10-17 Thread Seth P
On Monday, October 17, 2016 at 3:58:36 PM UTC-4, Mike Bayer wrote:
>
> that error is there right now because we don't emit the "col IS NULL" 
> SQL within that section of the persistence code. 
>
> took me a long time to find the history on this because I thought it had 
> been discussed but looks like the answer was "no immediate plans": 
> https://bitbucket.org/zzzeek/sqlalchemy/issues/2127#comment-9011753 
>
> that is, we can't just drop that assertion without adding logic to alter 
> the SQL for some parameters. 
>
 
I see. Makes sense. Thanks.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] ORM and table with no primary key

2016-10-17 Thread Mike Bayer



On 10/17/2016 03:36 PM, Seth P wrote:

I realize that the orm really wants/needs a table to have a primary key:
http://docs.sqlalchemy.org/en/rel_1_1/faq/ormconfiguration.html?#how-do-i-map-a-table-that-has-no-primary-key

Alas I have to deal with an existing table with no primary key. That
said, it does have a unique constraint on a subset of the columns,
though some of them are nullable (and indeed contain nulls). I've set up
a declarative model with these columns labeled as primary_key=True, and
things seem to work... until they don't, e.g. when calling delete() on
some objects followed by flush():
sqlalchemy.orm.exc.FlushError: Can't delete from table
MY_SCHEMA.my_table using NULL for primary key value on column
my_table.MY_COLUMN_1

I know this is a long shot, but is there any way to tell the orm not to
be such a stickler for detail, and just go ahead and emit the sql? I
dread not being able to use the orm...


that error is there right now because we don't emit the "col IS NULL" 
SQL within that section of the persistence code.


took me a long time to find the history on this because I thought it had 
been discussed but looks like the answer was "no immediate plans":

https://bitbucket.org/zzzeek/sqlalchemy/issues/2127#comment-9011753

that is, we can't just drop that assertion without adding logic to alter 
the SQL for some parameters.






--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and
Verifiable Example. See http://stackoverflow.com/help/mcve for a full
description.
---
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] ORM and table with no primary key

2016-10-17 Thread Seth P
I realize that the orm really wants/needs a table to have a primary key: 
http://docs.sqlalchemy.org/en/rel_1_1/faq/ormconfiguration.html?#how-do-i-map-a-table-that-has-no-primary-key

Alas I have to deal with an existing table with no primary key. That said, 
it does have a unique constraint on a subset of the columns, though some of 
them are nullable (and indeed contain nulls). I've set up a declarative 
model with these columns labeled as primary_key=True, and things seem to 
work... until they don't, e.g. when calling delete() on some objects 
followed by flush():
sqlalchemy.orm.exc.FlushError: Can't delete from table MY_SCHEMA.my_table 
using NULL for primary key value on column my_table.MY_COLUMN_1

I know this is a long shot, but is there any way to tell the orm not to be 
such a stickler for detail, and just go ahead and emit the sql? I dread not 
being able to use the orm...

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.