Commit Graph

1084 Commits

Author SHA1 Message Date
Mike Bayer 0a234fee4b Implement DDL visitor for PG ENUM with schema translate support
Fixed issue where the :class:`_postgresql.ENUM` type would not consult the
schema translate map when emitting a CREATE TYPE or DROP TYPE during the
test to see if the type exists or not.  Additionally, repaired an issue
where if the same enum were encountered multiple times in a single DDL
sequence, the "check" query would run repeatedly rather than relying upon a
cached value.

Fixes: #5520
Change-Id: I79f46e29ac0168e873ff178c242f8d78f6679aeb
(cherry picked from commit c290a40a543f8355ee712e2e565698b6ebdb162f)
2020-08-19 10:46:49 -04:00
Mike Bayer 8b34f3c4bb Deliver straight BinaryExpr w/ no negate for any() / all()
Adjusted the :meth:`_types.ARRAY.Comparator.any` and
:meth:`_types.ARRAY.Comparator.all` methods to implement a straight "NOT"
operation for negation, rather than negating the comparison operator.

Fixes: #5518
Change-Id: I87ee9278c321aafe51a679fcfcbb5fbb11307fda
(cherry picked from commit 8bc793c4db)
2020-08-18 14:19:35 -04:00
Gord Thompson 765478888c Fix mysql CREATE TABLE / COLLATE issue
Fixes: #5411
Change-Id: Ib0c53f5ed3f9d3ff0586580c9a9cce73b4b870f4
(cherry picked from commit 32e0b128f6)
2020-08-09 18:02:10 -06:00
Mike Bayer 2eaf2a9785 Fixes for MySQL 8
MySQL 8.0.19 has some changes to how it reports on display widths
for int types (seems like it omits it in some cases), and also
no longer cares about the length for YEAR.   Another adjustment
to the ordering of constraints reported in one case also.
At least one CI machine is at 8.0.21 now.

Change-Id: Ie2101bed3ad75dcbb62cd05abe95ef14ad895cf5
(cherry picked from commit 5668fd73ea)
2020-08-05 22:06:34 -04:00
Mike Bayer c0e76578f1 Add MariaDB 1927 to is_disconnect codes
Added MariaDB code 1927 to the list of "disconnect" codes, as recent
MariaDB versions apparently use this code when the database server was
stopped.

Fixes: #5493
Change-Id: I63f1d692f36cb0411ead278556e3f8c64ab72ea4
(cherry picked from commit 2a94625402)
2020-08-05 10:35:25 -04:00
Jim Bosch a8c9e8d723 Ensure is_comparison passed for PG RANGE op() methods
Fixed issue where the return type for the various RANGE comparison
operators would itself be the same RANGE type rather than BOOLEAN, which
would cause an undesirable result in the case that a
:class:`.TypeDecorator` that defined result-processing behavior were in
use.  Pull request courtesy Jim Bosch.

Fixes: #5476
Closes: #5477
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5477
Pull-request-sha: 925b117e0c

Change-Id: I52ab4d4362d379c8253990f9d328a40990a64520
(cherry picked from commit 07e57a0330)
2020-07-26 16:57:43 -04:00
Gord Thompson 1fc759d3b1 Fix mssql dialect escaping object names containing ']'
Fixes: #5467
Change-Id: I054ec219717ba62847a9daf1214e215dd6b70633
(cherry picked from commit 547e959157)
2020-07-18 07:37:48 -06:00
Mike Bayer e0b5e48796 Use index name to determine if an index is for the PK
Fixed bug in Oracle dialect where indexes that contain the full set of
primary key columns would be mistaken as the primary key index itself,
which is omitted, even if there were multiples.  The check has been refined
to compare the name of the primary key constraint against the index name
itself, rather than trying to guess based on the columns present in the
index.

Fixes: #5421
Change-Id: I47c2ccdd0b13977cfd9ef249d4de06371c4fb241
(cherry picked from commit ca56d8dc32)
2020-06-25 12:46:05 -04:00
Thodoris Sotiropoulos 52c50fee2d Add 'exists' to SQLite's reserved keywords
Added "exists" to the list of reserved words for SQLite so that this word
will be quoted when used as a label or column name. Pull request courtesy
Thodoris Sotiropoulos.

Fixes: #5395
Closes: #5396
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5396
Pull-request-sha: 5608317a38

Change-Id: Ia4769de2dec159dcf282eb4b30c11560da51a5c7
(cherry picked from commit ed4a4896ae)
2020-06-11 10:53:47 -04:00
Gord Thompson 5d118a09af Fix connection string escaping for mssql+pyodbc
Fixes: #5373
Change-Id: Ia41e8f1ef8644c54d23ebfdf3f909c785adf0fb0
(cherry picked from commit 14bc09203a)
2020-06-04 13:31:55 -06:00
mike bayer 77e3e51446 Merge "Support multiple dotted sections in mssql schema names" into rel_1_3 2020-06-01 19:43:13 +00:00
Mike Bayer dd0c170151 Support multiple dotted sections in mssql schema names
Refined the logic used by the SQL Server dialect to interpret multi-part
schema names that contain many dots, to not actually lose any dots if the
name does not have bracking or quoting used, and additionally to support a
"dbname" token that has many parts including that it may have multiple,
independently-bracketed sections.

This fix addresses #5364 to some degree but probably does not
resolve it fully.

References: #5364
Fixes: #5366
Change-Id: I460cd74ce443efb35fb63b6864f00c6d81422688
(cherry picked from commit 9aff0102813900fd7bc2120df5e1cfa169edb44f)
2020-06-01 15:38:53 -04:00
Gord Thompson 2c2bdceab7 Fix is_disconnect false positive for mssql+pyodbc
Fixed an issue where the ``is_disconnect`` function in the SQL Server
pyodbc dialect was incorrectly reporting the disconnect state when the
exception messsage had a substring that matched a SQL Server ODBC error
code.

Fixes: #5359
Change-Id: I450c6818405a20f4daee20d58fce2d5ecb33e17f
(cherry picked from commit ddff320473)
2020-06-01 06:03:55 -06:00
mike bayer a1471ace95 Merge "SYBASE: Added offset support" into rel_1_3 2020-05-28 16:42:38 +00:00
snowman2 3510ffee1f SYBASE: Added offset support
Fixes: #5294

### Description
Fix for https://github.com/sqlalchemy/sqlalchemy/issues/5294#issue-610311455

I tested it against our database (Adaptive Server Enterprise/16.0 SP02) with `pyodbc+sybase`

### Checklist

This pull request is:

- [x] A short code fix for #5294
- [x] Added tests.

Closes: #5312
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5312
Pull-request-sha: f62c14825f

Change-Id: Ic716e17a6f654deef78781cefc3f16333cd725c3
(cherry picked from commit 360583a00a)
2020-05-24 06:15:25 -06:00
RobotScribe 7577855d0b Add with_for_update mysql new functionalities
Fixes: #4860

# Description
Add nowait, skip_lock, of arguments to for_update_clause for mysql

### Checklist

This pull request is:

- [ ] A documentation / typographical error fix
	- Good to go, no issue or tests are needed
- [ ] A short code fix
	- please include the issue number, and create an issue if none exists, which
	  must include a complete example of the issue.  one line code fixes without an
	  issue and demonstration will not be accepted.
	- Please include: `Fixes: #<issue number>` in the commit message
	- please include tests.   one line code fixes without tests will not be accepted.
- [x] A new feature implementation
	- please include the issue number, and create an issue if none exists, which must
	  include a complete example of how the feature would look.
	- Please include: `Fixes: #<issue number>` in the commit message
	- please include tests.

**Have a nice day!**

Closes: #5290
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5290
Pull-request-sha: 490e822e73

Change-Id: Ibd2acc47b538c601c69c8fb954776035ecab4c6c
(cherry picked from commit 103260ddb4)
2020-05-24 05:32:32 -06:00
Gord Thompson 4382299a49 Stop converting mssql datetime.time parameters to datetime.datetime
Fixes: #5339
Change-Id: Ida75422d8c3fdfc7adae68e547d88df49368a693
(cherry picked from commit 9a04c2f657)
2020-05-23 07:05:00 -06:00
Mike Bayer 1616562a15 Don't emit pyodbc "no driver" warning for empty URL
Fixed an issue in the pyodbc connector such that a warning about pyodbc
"drivername" would be emitted when using a totally empty URL.  Empty URLs
are normal when producing a non-connected dialect object or when using the
"creator" argument to create_engine(). The warning now only emits if the
driver name is missing but other parameters are still present.

Fixes: #5346
Change-Id: I0ee6f5fd5af7faca63bf0d7034410942f40834a8
(cherry picked from commit 29534cf139)
2020-05-22 13:16:02 -04:00
Federico Caselli 228c582cdc SQLite 3.31 added support for computed column.
This change enables their support in SQLAlchemy when targeting SQLite.

Fixes: #5297
Change-Id: Ia9f21a49e58fc977e3c669b8176036c95d93b9c8
(cherry picked from commit 40fdcec6dfd6444a85a15e42065ce3a20e82e99f)
2020-05-19 19:34:47 +02:00
Mike Bayer 02a5abb745 Use cx_oracle.LONG_STRING /LONG_BINARY for CLOB/BLOB
Changed the implementation of fetching CLOB and BLOB objects to use
cx_Oracle's native implementation which fetches CLOB/BLOB objects inline
with other result columns, rather than performing a separate fetch. As
always, this can be disabled by setting auto_convert_lobs to False.

As part of this change, the behavior of a CLOB that was given a blank
string on INSERT now returns None on SELECT, which is now consistent with
that of VARCHAR on Oracle.

Fixes: #5314
Change-Id: I7b46c91704b6f5d6c157e083505dac6e0cb3ef6e
(cherry picked from commit fb28e40b31)
2020-05-09 09:51:36 -04:00
Federico Caselli 896da59aa4 Support ARRAY of Enum, JSON or JSONB
Added support for columns or type :class:`.ARRAY` of :class:`.Enum`,
:class:`.JSON` or :class:`_postgresql.JSONB` in PostgreSQL.
Previously a workaround was required in these use cases.
Raise an explicit :class:`.exc.CompileError` when adding a table with a
column of type :class:`.ARRAY` of :class:`.Enum` configured with
:paramref:`.Enum.native_enum` set to ``False`` when
:paramref:`.Enum.create_constraint` is not set to ``False``

Fixes: #5265
Fixes: #5266
Change-Id: I83a2d20a599232b7066d0839f3e55ff8b78cd8fc
(cherry picked from commit aaec1bdedf)
2020-04-20 11:54:31 -04:00
Mike Bayer 3294998c64 Pass connection to TablesTest.insert_data()
towards the goal of reducing verbosity and repetition
in test fixtures as well as that we are moving to
connection only for execution, move the insert_data()
classmethod to accept a connection and adjust all
fixtures to use it.

Change-Id: I3bf534acca0d5f4cda1d4da8ae91f1155b829b09
(cherry picked from commit 5c010c097352c783729e210018b95130ef94a926)
2020-04-15 11:16:12 -04:00
Mike Bayer 44cdd490b2 Gracefully skip isolation level if no row returned
Fixed issue in MySQL dialect when connecting to a psuedo-MySQL database
such as that provided by ProxySQL, the up front check for isolation level
when it returns no row will not prevent the dialect from continuing to
connect. A warning is emitted that the isolation level could not be
detected.

Fixes: #5239
Change-Id: I4a240386a0d38bd90733819495ce50e37fe2234c
(cherry picked from commit 978755e851)
2020-04-07 19:22:15 -04:00
Gord Thompson 4a03d2100e Replace engine.execute w/ context manager (step1)
First (baby) step at replacing engine.execute
calls in test code with the new preferred way
of executing. MSSQL was targeted because it was
the easiest for me to test locally.

Change-Id: Id2e02f0e39007cbfd28ca6a535115f53c6407015
(cherry picked from commit 60f627cbd0)
2020-04-06 16:08:42 -04:00
mike bayer 0147e3c364 Don't include PG INCLUDE columns as regular index columns
Fixed issue where a "covering" index, e.g. those which have an  INCLUDE
clause, would be reflected including all the columns in INCLUDE clause as
regular columns.  A warning is now emitted if these additional columns are
detected indicating that they are currently ignored.  Note that full
support for "covering" indexes is part of 🎫`4458`.  Pull request
courtesy Marat Sharafutdinov.

Fixes: #5205
Closes: #5206
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5206
Pull-request-sha: 512a3817bb

Change-Id: I3196a2bf77dc5a6abd85b2fbf0ebff1b30d4fb00
(cherry picked from commit ee9bd719b7)
2020-03-18 19:29:05 -04:00
Federico Caselli 5d963ae620 Support inspection of computed column
Added support for reflection of "computed" columns, which are now returned
as part of the structure returned by :meth:`.Inspector.get_columns`.
When reflecting full :class:`.Table` objects, computed columns will
be represented using the :class:`.Computed` construct.

Also improve the documentation in :meth:`Inspector.get_columns`, correctly
listing all the returned keys.

Fixes: #5063
Fixes: #4051

Closes: #5064
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5064
Pull-request-sha: ba00fc321ce468f8885aad23b3dd33c789e50fbe

Change-Id: I789986554fc8ac7f084270474d0b2c12046b1cc2
(cherry picked from commit 62b7dace0c)
2020-03-16 09:46:03 -04:00
Mike Bayer 19b248c14c Include schema in all_tab_comments query
Fixed regression / incorrect fix caused by fix for 🎫`5146` where the
Oracle dialect reads from the "all_tab_comments" view to get table comments
but fails to accommodate for the current owner of the table being
requested, causing it to read the wrong comment if multiple tables of the
same name exist in multiple schemas.

Fixes: #5146
Change-Id: Id79fbaa81b0e36cd4af60c48e4ab35c593ace057
(cherry picked from commit f1429823d3)
2020-03-12 23:13:35 -04:00
Gord Thompson 3c353ec9e3 Reflect comments from any table accessible by the current user
Fixed a reflection bug where table comments could only be retrieved for
tables actually owned by the user but not for tables visible to the user
but owned by someone else.  Pull request courtesy Dave Hirschfeld.

Fixes: #5146
Closes: #5147
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5147
Pull-request-sha: 0651e3bed0

Change-Id: If970fda10d6adf04d926d38df1a567df1de9f7b9
(cherry picked from commit 0c294d356f)
2020-03-10 10:42:38 -04:00
Mike Bayer 1a13a80a35 Render VALUES within composed MySQL on duplicate key expressions
Fixed issue in MySQL :meth:`.mysql.Insert.on_duplicate_key_update` construct
where using a SQL function or other composed expression for a column argument
would not properly render the ``VALUES`` keyword surrounding the column
itself.

Fixes: #5173
Change-Id: I16d39c2fdb8bbb7f3d1b2ffdd20e1bf69359ab75
(cherry picked from commit 57b2aae0d9)
2020-03-04 17:46:55 -05:00
Eric Borczuk 4df1823500 While parsing for check constraints, ignore newline characters in the check condition
Fixed bug where PostgreSQL reflection of CHECK constraints would fail to
parse the constraint if the SQL text contained newline characters. The
regular expression has been adjusted to accommodate for this case. Pull
request courtesy Eric Borczuk.

Fixes: #5170
Closes: #5172
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5172
Pull-request-sha: 5701b7f09f

Change-Id: If727e9140b645e8b685c3476fb0fa4417c1e6526
(cherry picked from commit 0fe528483a)
2020-02-29 17:46:23 -05:00
Mike Bayer 3362b0ceb1 Pass DDLCompiler IdentifierPreparer to visit_ENUM
Fixed issue where the "schema_translate_map" feature would not work with a
PostgreSQL native enumeration type (i.e. :class:`.Enum`,
:class:`.postgresql.ENUM`) in that while the "CREATE TYPE" statement would
be emitted with the correct schema, the schema would not be rendered in
the CREATE TABLE statement at the point at which the enumeration was
referenced.

Fixes: #5158
Change-Id: I41529785de2e736c70a142c2ae5705060bfed73e
(cherry picked from commit 89b8c343ed)
2020-02-17 15:36:16 -05:00
Mike Bayer 086c798655 Further refine fractional seconds datetimeoffset fixture
in 55f6d61e85 we still
forgot to accommodate for Python 3 timezone constructor
rejecting fractional minutes so the test further needs lambdas
to prevent the constructor from invoking for Python versions
less than 3.7

Change-Id: I02a83888f5ffbbe53ed0ce16c46a70942add4a3c
(cherry picked from commit a8b4ea8819)
2020-02-17 09:43:18 -05:00
Mike Bayer 9ec151bbe4 Fractional seconds starts at Python 3.7
CI didn't notice that the fractional seconds in the new SQL Server
DATETIMEOFFSET test are not available on Python 3.6. It was
inadvertently assumed this was a Python 2 incompatibility.

Change-Id: I9839eafbf7c37512eef1ecf666846983f9651c02
(cherry picked from commit 55f6d61e85)
2020-02-13 15:44:07 -05:00
Gord Thompson e9544a3be1 Fix handling of None as parameter for a datetimeoffset column
Fixed issue where the :class:`.mssql.DATETIMEOFFSET` type would not
accommodate for the ``None`` value, introduced as part of the series of
fixes for this type first introduced in 🎫`4983`, 🎫`5045`.
Additionally, added support for passing a backend-specific date formatted
string through this type, as is typically allowed for date/time types on
most other DBAPIs.

Fixes: #5132
Change-Id: Iab05d67382e0f550474d50e0c3c1c888521b678a
(cherry picked from commit 532ddb0fa7)
2020-02-10 18:28:05 -05:00
Federico Caselli 07fda81b2e Add pyproject
- Added pyproject.toml with black arguments
- Updated black version in precommit hook
- Reformatted the code

Fixes: #5100
Closes: #5103
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5103
Pull-request-sha: 795fd5f896

Change-Id: I14eedbaa51fb531cbf90fcefe6a1e07c8a565625
(cherry picked from commit f49a3fc02c03e39b3d34da9dfba4fe46d71c4aff)
2020-01-27 16:57:27 -05:00
Gord Thompson f00b584d54 Improve regex parsing of CHECK constraints for PostgreSQL.
Fixed issue where the PostgreSQL dialect would fail to parse a reflected
CHECK constraint that was a boolean-valued function (as opposed to a
boolean-valued expression).

Fixes: #5039
Closes: #5044
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5044
Pull-request-sha: b6903c6564

Change-Id: I7d39b104a8ce346cb593d541c1b4e5eab88867f9
(cherry picked from commit d8ac1e9e6b)
2020-01-18 09:32:35 -05:00
Gord Thompson b39bc68ab7 Fix DATETIMEOFFSET formatting to preserve fractional seconds.
Fixed issue where a timezone-aware ``datetime`` value being converted to
string for use as a parameter value of a :class:`.mssql.DATETIMEOFFSET`
column was omitting the fractional seconds.

Fixes: #5045
Closes: #5046
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5046
Pull-request-sha: 99dc7b23f6

Change-Id: I971629466fe0675536bbdf55693f0c1821dfb3cc
(cherry picked from commit 0d316e42f0)
2019-12-31 19:29:56 -05:00
Federico Caselli bead618047 Fix test failures under Windows
Fixed a few test failures which would occur on Windows due to SQLite file
locking issues, as well as some timing issues in connection pool related
tests; pull request courtesy Federico Caselli.

Note the pool related issues were fixed by Mike in
I1a7162e67912d22c135fa517b687a073f8fd9151 but are being ticketed
here.

Fixes:  #4946
Closes: #5055
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5055
Pull-request-sha: 36925573af

Change-Id: Ic53ec82f5d588d0e26a2d033a17c6109900d7f63
(cherry picked from commit f461d710f9f848029603cf76f7c26725afdea11e)
2019-12-30 20:37:45 -05:00
Gord Thompson 1987215d00 Add DATETIMEOFFSET support for mssql+pyodbc
Repaired support for the :class:`.mssql.DATETIMEOFFSET` datatype on PyODBC,
by adding PyODBC-level result handlers as it does not include native
support for this datatype.  This includes usage of the Python 3 "timezone"
tzinfo subclass in order to set up a timezone, which on Python 2 makes
use of a minimal backport of "timezone" in sqlalchemy.util.

Fixes: #4983
Closes: #4986
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4986
Pull-request-sha: e3a5a8dda0

Change-Id: Ia4c7c0d1971c6c0492515bd5fa0b1799f07fee1c
(cherry picked from commit f521577f6e)
2019-11-29 12:07:18 -05:00
Mike Bayer d5a16a1283 Detect PyMySQL connection was killed
Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: https://github.com/PyMySQL/PyMySQL/issues/816
Fixes: #4945
(cherry picked from commit 31a66b5add)
2019-11-11 16:20:42 -05:00
Mike Bayer f26af5d617 Add type accessors for JSON indexed/pathed element access
Added new accessors to expressions of type :class:`.JSON` to allow for
specific datatype access and comparison, covering strings, integers,
numeric, boolean elements.   This revises the documented approach of
CASTing to string when comparing values, instead adding specific
functionality into the PostgreSQL, SQlite, MySQL dialects to reliably
deliver these basic types in all cases.

The change also delivers a new feature to the test exclusions
system so that combinations and exclusions can be used together.

Fixes: #4276
Change-Id: Ica5a926c060feb40a0a7cd60b9d6e061d7825728
(cherry picked from commit 01cbf4d7b8)
2019-11-11 14:38:06 -05:00
Mike Bayer a28674db3c Interpret empty LIMIT, expression LIMIT correctly
Fixed issue in MSSQL dialect where an expression-based OFFSET value in a
SELECT would be rejected, even though the dialect can render this
expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct.

Fixes: #4973
Change-Id: I040d34f781791c4ed5a727e1b8fb98c68ddd0622
(cherry picked from commit b3c3562ecf)
2019-11-09 16:13:13 -05:00
CaselIT 16eb92ea09 Support for generated columns
Added DDL support for "computed columns"; these are DDL column
specifications for columns that have a server-computed value, either upon
SELECT (known as "virtual") or at the point of which they are INSERTed or
UPDATEd (known as "stored").  Support is established for Postgresql, MySQL,
Oracle SQL Server and Firebird. Thanks to Federico Caselli for lots of work
on this one.

ORM round trip tests included.  The ORM makes use of existing
FetchedValue support and no additional ORM logic is present for
the basic feature.

It has been observed that Oracle RETURNING does not return the
new value of a computed column upon UPDATE; it returns the
prior value.  As this is very dangerous, a warning is emitted
if a computed column is rendered into the RETURNING clause
of an UPDATE statement.

Fixes: #4894
Closes: #4928
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4928
Pull-request-sha: d39c521d5a

Change-Id: I2610b2999a5b1b127ed927dcdaeee98b769643ce
(cherry picked from commit 602d1e6dfd538980bb8d513867b17dbc2b4b92dd)
2019-11-08 15:41:10 -05:00
Mike Bayer b1103f3453 Cache every key in reflection_cache
Fixed bug in :class:`.Inspector` where the cache key generation did not
take into account arguments passed in the form of tuples, such as the tuple
of view name styles to return for the PostgreSQL dialect. This would lead
the inspector to cache too generally for a more specific set of criteria.
The logic has been adjusted to include every keyword element in the cache,
as every argument is expected to be appropriate for a cache else the
caching decorator should be bypassed by the dialect.

Fixes: #4955
Change-Id: Icd97744323407977a3f7db26e8a63a1a5c576010
(cherry picked from commit 9fc54801c8)
2019-10-31 09:34:55 -04:00
Mike Bayer bf905106bf Refactor dialect tests for combinations
Dialect tests tend to have a lot of lists of types,
SQL constructs etc, convert as many of these to @combinations
as possible.

This is exposing that we don't have per-combination
exclusion rules set up which is making things a little bit
cumbersome.

Also set up a fixture that does metadata + DDL.

Change-Id: Ief820e48c9202982b0b1e181b87862490cd7b0c3
(cherry picked from commit 240d9a60cc)
2019-10-22 18:27:56 -04:00
Mike Bayer 8ccf0b688e Implment encoding_errors for cx_oracle
Added dialect-level flag ``encoding_errors`` to the cx_Oracle dialect,
which can be specified as part of :func:`.create_engine`.   This is passed
to SQLAlchemy's unicode decoding converter under Python 2, and to
cx_Oracle's ``cursor.var()`` object as the ``encodingErrors`` parameter
under Python 3, for the very unusual case that broken encodings are present
in the target database which cannot be fetched unless error handling is
relaxed.  The value is ultimately one of the Python "encoding errors"
parameters passed to ``decode()``.

Closes: #4801
Fixes: #4799
Change-Id: I1d542ba367bcd187347c54db1fee815f7890e71c
(cherry picked from commit d76cb72135)
2019-10-21 14:20:40 -04:00
Mike Bayer 8bb2b06436 Ensure SQL Server default schema name not interpreted as dot-separated tokens
Fixed an issue in the :meth:`.Engine.table_names` method where it would
feed the dialect's default schema name back into the dialect level table
function, which in the case of SQL Server would interpret it as a
dot-tokenized schema name as viewed by the mssql dialect, which would
cause the method to fail in the case where the database username actually
had a dot inside of it.  In 1.3, this method is still used by the
:meth:`.MetaData.reflect` function so is a prominent codepath. In 1.4,
which is the current master development branch, this issue doesn't exist,
both because :meth:`.MetaData.reflect` isn't using this method nor does the
method pass the default schema name explicitly.  The fix nonetheless
guards against the default server name value returned by the dialect from
being interpreted as dot-tokenized name under any circumstances by
wrapping it in quoted_name().

Fixes: #4923
Change-Id: I821bd38ed89b767eaca0bdffee7f8ba3baf82560
(cherry picked from commit f50c6a04067acf2cd2fc5e42d5acaa9206d9a078)
2019-10-17 22:13:58 -04:00
Mike Bayer 99b292c5c5 Use cx_Oracle.FIXED_NCHAR for sqltypes.NCHAR
The :class:`.sqltypes.NCHAR` datatype will now bind to the
``cx_Oracle.FIXED_NCHAR`` DBAPI data bindings when used in a bound
parameter, which supplies proper comparison behavior against a
variable-length string.  Previously, the :class:`.sqltypes.NCHAR` datatype
would bind to ``cx_oracle.NCHAR`` which is not fixed length; the
:class:`.sqltypes.CHAR` datatype already binds to ``cx_Oracle.FIXED_CHAR``
so it is now consistent that :class:`.sqltypes.NCHAR` binds to
``cx_Oracle.FIXED_NCHAR``.

Fixes: #4913
Change-Id: I5bb111f2e06bbdd525bc5f716579baad31bbb3db
(cherry picked from commit e4a5da1c5a)
2019-10-15 11:57:31 -04:00
Mike Bayer 1723d7d59f Repair Oracle compat version check; dont warn if failed
Fixed regression in Oracle dialect that was inadvertently using max
identifier length of 128 characters on Oracle server 12.2 and greater even
though the stated contract for the remainder of the 1.3 series is  that
this value stays at 30 until version SQLAlchemy 1.4.  Also repaired issues
with the retrieval of the "compatibility" version, and removed the warning
emitted when the "v$parameter" view was not accessible as this was  causing
user confusion.

Fixes: #4898
Change-Id: Ieb7b3e093610896c5aa12d0789b63262e0ecf9d8
2019-10-09 17:17:54 -04:00
Mike Bayer a0f4790371 Apply quoting to SQL Server _switch_db
Added identifier quoting to the schema name applied to the "use" statement
which is invoked when a SQL Server multipart schema name is used within  a
:class:`.Table` that is being reflected, as well as for :class:`.Inspector`
methods such as :meth:`.Inspector.get_table_names`; this accommodates for
special characters or spaces in the database name.  Additionally, the "use"
statement is not emitted if the current database matches the target owner
database name being passed.

Fixes: #4883
Change-Id: I84419730e94aac3a88d331ad8c24d10aabbc34af
(cherry picked from commit 66a7befa0c)
2019-10-03 11:35:14 -04:00