[SQL-CVS] SQLObject/docs FAQ.txt,1.3,1.4
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-09-09 04:04:05
|
Update of /cvsroot/sqlobject/SQLObject/docs In directory sc8-pr-cvs1:/tmp/cvs-serv13289/docs Modified Files: FAQ.txt Log Message: Updated FAQ about non-integer IDs Index: FAQ.txt =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/docs/FAQ.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FAQ.txt 7 Sep 2003 19:14:43 -0000 1.3 --- FAQ.txt 9 Sep 2003 04:04:02 -0000 1.4 *************** *** 147,156 **** --------------- ! SQLObject requires that you use an integer primary key, usually ! defined in a specific way (``INT PRIMARY KEY AUTO_INCREMENT`` for ! MySQL, for instance, or ``SERIAL PRIMARY KEY`` for PostgreSQL). You ! cannot use strings or other kinds of values. ! This restriction will probably be removed soon. --- 147,178 ---- --------------- ! Yes, you can use non-integer IDs, but only in CVS_ now. ! .. _CVS: http://sqlobject.org/#anonymous-cvs ! ! If you use non-integer IDs, you will not be able to use automatic ! ``CREATE TABLE`` generation (i.e., ``createTable``). You also will ! have to give your own ID values when creating an object, like:: ! ! color = Something.new(id="blue", r=0, b=100, g=0) ! ! IDs are, and always will in future versions, be considered immutable. ! Right now that is not enforced; you can assign to the ``id`` ! attribute. But if you do you'll just mess everything up. This will ! probably be taken away sometime to avoid possibly confusing bugs ! (actually, assigning to ``id`` is almost certain to cause confusing ! bugs). ! ! If you are concerned about enforcing the type of IDs (which can be a ! problem even with integer IDs) you may want to do this:: ! ! def Color(SQLObject): ! def _init(self, id, connection=None): ! id = str(id) ! SQLObject._init(self, id, connection) ! ! Instead of ``str()`` you may use ``int()`` or whatever else you want. ! This will be resolved in a future version when ID column types can be ! declared like other columns. |