Oleg Broytmann a écrit : > On Fri, Jul 21, 2006 at 04:22:06PM +0200, Fran?ois wrote: > >> class Country(SQLObject): >> class sqlmeta: >> idName = "iso" >> idType = str >> name = StringCol(notNone = True) >> > > With this SQLObject creates an "iso" column declared as TEXT PRIMARY > KEY. I don't know if MySQL allows this. Please consult the docs. If it > doesn't - please report what column type it must be. > > Oleg. > Hello oleg, I hope your are better now :-)
In mysql doc [1] I've see : [...] |CHAR|, |VARCHAR|, |BINARY|, and |VARBINARY| columns, indexes can be created that use only the leading part of column values, using |/|col_name|/(/|length|/)| syntax to specify an index prefix length. |BLOB| and |TEXT| columns also can be indexed, but a prefix length /must/ be given. Prefix lengths are given in characters for non-binary string types and in bytes for binary string types. That is, index entries consist of the first /|length|/ characters of each column value for |CHAR|, |VARCHAR|, and |TEXT| columns, and the first /|length|/ bytes of each column value for |BINARY|, |VARBINARY|, and |BLOB| columns. Indexing only a prefix of column values like this can make the index file much smaller. See Section 7.4.3, “Column Indexes” <http://dev.mysql.com/doc/refman/4.1/en/indexes.html>. I have an old table created by MySQL Control center and its definition is : CREATE TABLE `country` ( `iso` char(2) NOT NULL default 'ch', `name_en` varchar(100) NOT NULL default 'Switzerland', ...... other fileds ...... PRIMARY KEY (`iso`) ); So the index is declared as CHAR type (and not TEXT) with the size 2. I don't know if it's possible to add perhaps an 'idSize' or 'idLenght' attribute in sqlmeta class ? The right definition for MySQL is : CREATE TABLE country ( iso CHAR(2) NOT NULL PRIMARY KEY, name varchar(100) NOT NULL ); I'm not a SQL specialist, so I don't know if it's a right table definition for other databases (SQL compliant) ? François [1] http://dev.mysql.com/doc/refman/4.1/en/create-table.html ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ sqlobject-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
