i've made something but before u jump on my overly generic ways of 
coding, here the matrix to be tested:

matrix/possibilities:

A. mangling: for those longer, try 2 of same kind (in one parent), 
both same  size, beginning same but diff. at the end, with diff after 
MAXLEN, e.g. sometable( vee...rylongcolumn1, vee..rylongcolumn2 ) - 
the columns should be mangled differently (just truncating will make 
them same)

B   length combinations
    * 'schema.table.column' <MAXLEN
    * 'schema.table.column' =MAXLEN
      'schema.table.column' >MAXLEN
       * each <MAXLEN
       * each =MAXLEN
       * each >MAXLEN
       * one less others longer  x3
       * one less others equal   x3
       * one equal others longer x3
       * one longer others less  x3
       * one longer others equal x3

C some column is primary_key: -> automatic sequence_name
      sequence_name = table+'_'+somecolumn+'_seq' 
        (len= len(table)+len(somecolumn)+1+4)
    * schema.sequence_name<MAXLEN
    * schema.sequence_name=MAXLEN
    * schema.sequence_name>MAXLEN
       * each <MAXLEN
       * each =MAXLEN
       * each >MAXLEN
       * first less other longer
       * first less other equal
       * first equal other less
       * first equal other longer
       * first longer other less
       * first longer other equal

D index -> any automatic naming?
E foreignkey, other constraints ?

========
question: is there a dialect that restricts overall size of a 
composite multilevel name (schema1.table2.column3), or all are sane 
enough and have limits only on single identifier length? 
schema1 table2 column3 each are single identifiers.
if only identifier length is at stake, then only our automatic-made 
names should be extra-checked (e.g. sequences, indexes, what else)

ciao
svilen


On Sunday 22 June 2008 23:27:43 Michael Bayer wrote:
> the fix is along these lines, and its dependent on PG's behavior of
> truncating, then appending "_colname_seq".   However, I've no idea
> what it does when tablename + colname add up to more than 60, or
> when colname alone is more than 60 - theres several variations
> here.
>
> theres also many workarounds here, including using autoload=True,
> as well as a Sequence object with the exact name.
>
> One way to obliterate the issue totally would be to use a
> PG-specific reflection on the column to get its default generator. 
>   Care to work up a set of tests for me (for at least #1 above ?)
>
>
> Index: lib/sqlalchemy/databases/postgres.py
> ===================================================================
> --- lib/sqlalchemy/databases/postgres.py      (revision 4870)
> +++ lib/sqlalchemy/databases/postgres.py      (working copy)
> @@ -781,9 +781,9 @@
>                   # TODO: this has to build into the Sequence
> object so we can get the quoting
>                   # logic from it
>                   if sch is not None:
> -                    exc = "select nextval('\"%s\".\"%s_%s_seq\"')"
> % (sch, column.table.name, column.name)
> +                    exc = "select nextval('\"%s\".\"%s_%s_seq\"')"
> % (sch, column.table.name[0:56], column.name)
>                   else:
> -                    exc = "select nextval('\"%s_%s_seq\"')" %
> (column.table.name, column.name)
> +                    exc = "select nextval('\"%s_%s_seq\"')" %
> (column.table.name[0:56], column.name)
>                   return
> self.execute_string(exc.encode(self.dialect.encoding))
>
>           return super(PGDefaultRunner,
> self).get_column_default(column)
>
> On Jun 22, 2008, at 4:11 PM, [EMAIL PROTECTED] wrote:
> > rom sqlalchemy import *
> > from sqlalchemy.orm import *
> > import sys
> > metadata = MetaData( sys.argv[1:] and sys.argv[1] or 'sqlite://')
> > metadata.bind.echo = 'echo' in sys.argv
> >
> > aa = 'itm'*30
> >
> > #56 works on postgres
> > #57 and above - not
> > item_table = Table( aa[:57],
> >        metadata,
> >        Column('id', Integer, primary_key=True),
> >        Column('name', String(50)))
> >
> > class Item(object):
> >    def __init__(self, name): self.name = name
> >    def __str__(self): return self.name
> > item_mapper = mapper(Item, item_table, )
> > metadata.create_all()
> >
> > session = create_session()
> >
> > session.save(Item('aaa'))
> > session.save(Item('vvvv'))
> > session.flush()
> >
> > items = session.query(Item)
> > for item in items: print item
> > ---------------
> > results in:
> > sqlalchemy.exceptions.ProgrammingError: (ProgrammingError)
> > relation
> > "itmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitm_id_se"
> > does not exist
> > 'select
> > nextval
> > (\'"itmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitmitm_id_
> >seq "\')'
> > None
> >
> > seems mangling should start for any len(name) > maxsize -
> > len("_id_seq")
>
> 


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