[sqlalchemy] autoloading with known columns

2011-02-02 Thread A.M.
Hello,

I am using autoload to load some of my application metadata for views, however, 
since some information cannot be extracted from the view (such as the primary 
key) and  because one UserDefinedType I am using cannot be recognized using 
reflection, I am passing certain column information into the Table __init__ 
method:

Table(viewname,
metadata,
Column('id',Integer,primary_key=True),
Column('acl',ACLItemArrayType,nullable=False),
autoload=True)

Unfortunately, I still get Did not recognize type 'aclitem' of column 'acl' 
because the column information is still trying to be reflected. Would it make 
sense for there to exist an option to exclude column names as part of table 
reflection and exclude those columns which are specified as part of Table()?

Cheers,
M

-- 
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.



Re: [sqlalchemy] autoloading with known columns

2011-02-02 Thread Michael Bayer

On Feb 2, 2011, at 4:50 PM, A.M. wrote:

 Hello,
 
 I am using autoload to load some of my application metadata for views, 
 however, since some information cannot be extracted from the view (such as 
 the primary key) and  because one UserDefinedType I am using cannot be 
 recognized using reflection, I am passing certain column information into the 
 Table __init__ method:
 
 Table(viewname,
   metadata,
   Column('id',Integer,primary_key=True),
   Column('acl',ACLItemArrayType,nullable=False),
   autoload=True)
 
 Unfortunately, I still get Did not recognize type 'aclitem' of column 'acl' 
 because the column information is still trying to be reflected.

it will emit that warning when it loads the full set of columns, but your 
ACLItemArrayType should be written into the Table metadata for the end result.

 Would it make sense for there to exist an option to exclude column names as 
 part of table reflection and exclude those columns which are specified as 
 part of Table()?

We currently have include_columns as a Table argument which works in the 
opposite direction, exclude_columns is doable, but the better solution here 
would be to allow you to register your new type with the dialect.   You can 
achieve that now through non-public API by adding PG's internal identifier for 
the type plus your type to ischema_names:

engine = create_engine('postgresql://')
engine.dialect.ischema_names['ACLARRAY'] = ACLItemArrayType





 
 Cheers,
 M
 
 -- 
 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.
 

-- 
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.