Michael Bayer ha scritto:
> the docs say "register_converter" is for custom types.  seems like  
> kind of a hack here ?  

As I can see, it is not an hack.

> why not make your own type ?
> 

I have tried to replace 'NUMERIC' with 'DECIMAL' or 'XDECIMAL';
the result is the same: pysqlite converts the column's value to a float.

I do not understand this behaviour, however, as for SQLite docs[1], 
every user defined type has the NUMERIC affinity (this means that SQLite 
treats it as a float, if the value can be converted to a float).

It seems that the only solution is to register a custom converter, but 
SQLAlchemy *must* add a space before the '(' in the col_spec.



[1]
2.1 Determination Of Column Affinity

The type affinity of a column is determined by the declared type of the 
column, according to the following rules:

    1. If the datatype contains the string "INT" then it is assigned 
INTEGER affinity.

    2. If the datatype of the column contains any of the strings "CHAR", 
"CLOB", or "TEXT" then that column has TEXT affinity. Notice that the 
type VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity.

    3. If the datatype for a column contains the string "BLOB" or if no 
datatype is specified then the column has affinity NONE.

    4. If the datatype for a column contains any of the strings "REAL", 
"FLOA", or "DOUB" then the column has REAL affinity

    5. Otherwise, the affinity is NUMERIC.


So, it seems that pysqlite just enforces the type affinity converting 
the column's value to the correspondind Python type
(NUMERIC -> REAL -> float).


Thanks and regards   Manlio Perillo


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to