/
py2-sqlalchemy-1.3.4-add-frontier-dialect.patch
102 lines (102 loc) · 3.59 KB
/
py2-sqlalchemy-1.3.4-add-frontier-dialect.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
diff --git a/lib/sqlalchemy/connectors/frontier.py b/lib/sqlalchemy/connectors/frontier.py
new file mode 100644
index 0000000..5cbb3d7
--- /dev/null
+++ b/lib/sqlalchemy/connectors/frontier.py
@@ -0,0 +1,26 @@
+# connectors/frontier.py
+# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
+#
+# This module is part of SQLAlchemy and is released under
+# the MIT License: http://www.opensource.org/licenses/mit-license.php
+
+from . import Connector
+import urllib
+
+class FrontierConnector(Connector):
+ driver = 'frontier'
+
+ @classmethod
+ def dbapi(cls):
+ return __import__('frontier')
+
+ def create_connect_args(self, url):
+ self.url_database = url.database
+
+ return [
+ [urllib.unquote_plus(url.host)] if url.host else [],
+ url.query
+ ]
+
+ def do_rollback(self, dbapi_connection):
+ pass
diff --git a/lib/sqlalchemy/dialects/oracle/__init__.py b/lib/sqlalchemy/dialects/oracle/__init__.py
index 9f1e15b..d06e3e9 100644
--- a/lib/sqlalchemy/dialects/oracle/__init__.py
+++ b/lib/sqlalchemy/dialects/oracle/__init__.py
@@ -8,6 +8,7 @@
from . import base # noqa
from . import cx_oracle # noqa
from . import zxjdbc # noqa
+from . import frontier # noqa
from .base import BFILE
from .base import BINARY_DOUBLE
from .base import BINARY_FLOAT
diff --git a/lib/sqlalchemy/dialects/oracle/frontier.py b/lib/sqlalchemy/dialects/oracle/frontier.py
new file mode 100644
index 0000000..74cde5e
--- /dev/null
+++ b/lib/sqlalchemy/dialects/oracle/frontier.py
@@ -0,0 +1,52 @@
+# oracle/frontier.py
+# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
+#
+# This module is part of SQLAlchemy and is released under
+# the MIT License: http://www.opensource.org/licenses/mit-license.php
+
+"""
+.. dialect:: oracle+frontier
+ :name: Frontier
+ :dbapi: frontier
+ :connectstring: oracle+frontier://@serverURL[/dbname]
+ :driverurl: http://frontier.cern.ch
+
+"""
+from sqlalchemy.connectors.frontier import FrontierConnector
+from sqlalchemy.dialects.oracle.base import OracleCompiler, OracleDialect
+
+class OracleCompiler_frontier(OracleCompiler):
+
+ def __init__(self, *args, **kwargs):
+ super(OracleCompiler_frontier, self).__init__(*args, **kwargs)
+
+ def visit_table(self, table, asfrom=False, iscrud=False, ashint=False,
+ fromhints=None, **kwargs):
+ if asfrom or ashint:
+ if getattr(table, "schema", None):
+ ret = self.preparer.quote_schema(table.schema,
+ table.quote_schema) + \
+ "." + self.preparer.quote(table.name,
+ table.quote)
+ elif self.dialect.default_schema_name:
+ ret = self.preparer.quote_schema(self.dialect.default_schema_name,
+ table.quote_schema) + \
+ "." + self.preparer.quote(table.name,
+ table.quote)
+ else:
+ ret = self.preparer.quote(table.name, table.quote)
+ if fromhints and table in fromhints:
+ ret = self.format_from_hint_text(ret, table,
+ fromhints[table], iscrud)
+ return ret
+ else:
+ return ""
+
+class OracleDialect_frontier(FrontierConnector, OracleDialect):
+
+ statement_compiler = OracleCompiler_frontier
+
+ def _get_default_schema_name(self, connection):
+ return self.url_database
+
+dialect = OracleDialect_frontier