sqlalchemy-bot / test_alembic_1

0 stars 0 forks source link

DBAPI-agnostic dialect use for offline mode #304

Open sqlalchemy-bot opened 9 years ago

sqlalchemy-bot commented 9 years ago

Migrated issue, originally created by Michael Bayer (zzzeek)

The psycopg2 dialect doubles up percent signs. in offline mode, there's no DBAPI thus we should use the default dialect minus DBAPI. However SQLAlchemy does not expose this. We may want upstream SQLA to support a url of the form "postgresql+generic://" to make this possible, but the solution should be agnostic of backend (still might require adding the name "generic" to each module).

sqlalchemy-bot commented 9 years ago

Michael Bayer (zzzeek) wrote:

#!diff

diff --git a/lib/sqlalchemy/dialects/postgresql/__init__.py b/lib/sqlalchemy/dialects/postgresql/__init__.py
index 98fe6f0..dfa27a9 100644
--- a/lib/sqlalchemy/dialects/postgresql/__init__.py
+++ b/lib/sqlalchemy/dialects/postgresql/__init__.py
@@ -6,8 +6,11 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php

 from . import base, psycopg2, pg8000, pypostgresql, zxjdbc, psycopg2cffi
+import imp

 base.dialect = psycopg2.dialect
+generic = imp.new_module("generic")
+generic.dialect = base.generic

 from .base import \
     INTEGER, BIGINT, SMALLINT, VARCHAR, CHAR, TEXT, NUMERIC, FLOAT, REAL, \
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 22c66db..94c629a 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -2875,3 +2875,5 @@ class PGDialect(default.DefaultDialect):
             }

         return domains
+
+generic = PGDialect
sqlalchemy-bot commented 6 years ago

Michael Bayer (zzzeek) wrote:

perhaps just a compiler flag "sqlscript=True" or something like that

sqlalchemy-bot commented 9 years ago

Changes by Michael Bayer (zzzeek):