Hi,

We're using PostgreSQL's BIT type to store bit-strings (
http://www.postgresql.org/docs/current/static/datatype-bit.html), and (at
least as of SQLA 0.6.6) the PostgreSQL dialect's BIT type doesn't seem to
support those kinds of fields -- it just issues "BIT" when creating the
tables, and we get 1-bit fields! At the moment (for table creation at least)
we're getting around this using the following:

class PG_BIT(sqlalchemy.dialects.postgresql.BIT):
    def __init__(self, length=None, *args, **kw):
        # Takes one positional arg, the bit length. Can be omitted
        self._bit_length = length

@sqlalchemy.ext.compiler.compiles(PG_BIT)
def compile_PG_BIT(element, compiler, **kw):
    if element._bit_length:
        return "BIT(%d)" % element._bit_length
    else:
        return compiler.visit_BIT(element, **kw)


and using PG_BIT everywhere we'd want to use BIT. Obviously, though, it'd be
great if SQLAlchemy supported this better. I'm very happy to try and work up
a patch myself, but I'd appreciate advice on :
   - what I should try to patch (postgresql.BIT and
postgresql.base.PGTypeCompiler are my first guesses)
   - what kind of coding / testing practices I should observe
   - should I try and write a patch against hg tip? against the 0.6.6
release?
   - is there anything I'm missing?

Thanks!
Rami

-- 
Rami Chowdhury
"Never assume malice when stupidity will suffice." -- Hanlon's Razor
+44-7581-430-517 / +1-408-597-7068 / +88-0189-245544

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to