Comments (5)
Michael Bayer (@zzzeek) wrote:
we are going to use UNIQUE to put a clustered unique constraint on all the "primary keys" specified in a Table when its created. only the first primary_key in the column list will actually be called 'primary key'.
as far as when we reflect such a table back from the DB, im not sure yet. how do we differentiate an ordinary unique index from one that is a clustered primary key ? might want to skip this step.
multiple primary keys are already supported by the Mapper if you explicitly send the "primary_keys" argument, which will name any arbitrary cols as primary keys to be used for an object's ID. I might just leave it this way, so that a multi-primary-key ORM is possible, just needs a little more explicitness in some cases.
from sqlalchemy.
Michael Bayer (@zzzeek) wrote:
ok, that went differently than I thought. both postgres and sqlite support a separate PRIMARY KEYS (col1, col2) clause. however, when you use it with sqlite, sqlite suddenly will not autoincrement anymore.
so, the default behavior when a table has multiple primary keys is to use PRIMARY KEYS (col1, col2). with SQLIte, it creates the first column as a PRIMARY KEY, then creates a UNIQUE index encompassing all the primary keys. it also will reflect a table with a UNIQUE index containing a primary key as a multiple primary key table.
when using tables with multi-primary keys, its safe to assume the first primary key column is autoincrementing. successive keys, its not. it works with postgres, not with sqlite. so in that case, an application has to populate all but the first primary key on a table or object instance before INSERT or objectstore.commit().
changeset 651. primary key unit tests added previously to test/objectstore.py and test/engines.py.
from sqlalchemy.
Changes by Michael Bayer (@zzzeek):
- added labels: high priority
- changed title from "write unit tests for ORM with a basic multiple pri" to "tables with multiple primary keys cant be created"
- set milestone to "first release"
from sqlalchemy.
Changes by Michael Bayer (@zzzeek):
- removed labels: orm
- added labels: schema
from sqlalchemy.
Changes by Michael Bayer (@zzzeek):
- changed status to closed
from sqlalchemy.
Related Issues (20)
- defaultload().contains_eager() option not expired HOT 2
- Creating an index concurrently using asynpg freezes the program HOT 5
- Some UUIDs are not written correctly in Sqlite HOT 4
- NoForeignKeysError inconsistent error? HOT 5
- Enums are not created in new type alias syntax HOT 12
- IndexError in Query with string literal + repeated ORM attribute HOT 4
- Parameter substitution fails when statement has a postgres style cast HOT 5
- reflecting oracle synonym of synonym over dblink HOT 4
- Changing decimal separator to comma using locale.setlocale causes crash on MSSQL columns of decimal type HOT 3
- Generated syntax error when using funcs in server_default in MySQL
- NoForeignKeysError and AmbiguousForeignKeysError after upgrade to 2.x HOT 5
- selectin_polymorphic does not work for multiple level joined inheritance HOT 2
- ColumnCollection.get(col, default) types as Optional even with default HOT 2
- bulk_save_objects() w/ return defaults writes incorrect identity key HOT 4
- `sqlalchemy.utils.langhelpers.TypingOnly` too rigidly prevents special dunders from appearing HOT 5
- func.count argument typing issue HOT 1
- Bundle labels are wrong for new style select only (query works ?!) HOT 9
- Use of `raise NotImplementedError` instead of `NotImplemented` HOT 1
- Design a Repository pattern with sqlalchemy HOT 1
- Add `name` to `with_polymorphic ` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy.