add API to DialectKWArgs to add new arguments

Issue #2962 resolved
Mike Bayer repo owner created an issue

also make sure the error message points to this

from sqlalchemy.dialects.postgresql import base
base.PGDialect.construct_arguments.append((PrimaryKeyConstraint, {"fillfactor": None}))

Comments (10)

  1. Mike Bayer reporter

    Also look into adding an API to allow arguments to be added after the fact, e.g.:

    index.kwargs['mysql_length'] = 191
    
  2. Mike Bayer reporter

    confirm that "table.mysql_engine = 'InnoDB'" does not have any effect, that's not the API.

  3. Chris Dent

    I tried to do some work on this but made very little headway. To try to get a better understanding of how things work the first thing I did was change the dict underlying DialectKWArgs to a standard dict. Curiously this makes the assigning to table.kwargs['mysql_engine'] impact on the type of table created, but index.kwargs['mysql_length'] doesn't appear to do anything. I assume this is because of differences between handling in create table and visit_create_index handling in sqlalchemy/dialects/mysql/base.py, but I can't be sure.

    This is the first time I've dug this deeply into the internals and a) I'm impressed b) overwhelmed, so will have to take a break until tomorrow and perhaps some feedback can guide me a bit further.

  4. Mike Bayer reporter

    im looking right now and this one is not so easy. DialectKWArgs maintains two different dictionaries and at the moment relies upon being able to generate them just once at construction time. they aren't kept in sync following that. it would have to be rearranged to support this.

  5. Mike Bayer reporter
    • The new dialect-level keyword argument system for schema-level constructs has been enhanced in order to assist with existing schemes that rely upon addition of ad-hoc keyword arguments to constructs.
    • To suit the use case of allowing custom arguments at construction time, the :meth:.DialectKWArgs.argument_for method now allows this registration. fixes #2962

    → <<cset 33f07202ce2d>>

  6. Mike Bayer reporter

    OK this was actually pretty involved. You can again just add keywords to index.kwargs, and there is also a new method <class>.argument_for() which will allow the addition of new constructor arguments.

  7. Chris Dent

    Awesome thank you. Thanks also for making my brain bigger, that is a rather large change set and has quite a bit I can learn from.

  8. Log in to comment