Commit Graph

85 Commits

Author SHA1 Message Date
Mike Bayer 4f054550b7 Propagate kwargs for mysql concat, match
Fixed bug where the MySQL "concat" and "match" operators failed to
propagate kwargs to the left and right expressions, causing compiler
options such as "literal_binds" to fail.

Also adds non-interpreted **kw for visit_create_index, visit_typeclause

Change-Id: Iaf54ac18949cc6a54f50678125f010b4f12c5673
Fixes: #4136
2017-11-13 09:23:14 -05:00
Mike Bayer 57f7788ec2 Get MariaDB normalized version relative to "MariaDB" token
Fixed regression from 1.2.0b3 where "MariaDB" version comparison can
fail for some particular MariaDB version strings under Python 3.

Change-Id: Iedf49f40c1614ccedf63e0fa26719dd704da104d
Fixes: #4115
2017-10-20 16:08:47 -04:00
Mike Bayer 29b752f8b2 Support mariadb 10.2
Fixed issue where CURRENT_TIMESTAMP would not reflect correctly
in the MariaDB 10.2 series due to a syntax change, where the function
is now represented as ``current_timestamp()``.

Fixes: #4096

MariaDB 10.2 now supports CHECK constraints (warning: use version 10.2.9
or greater due to upstream issues noted in 🎫`4097`).  Reflection
now takes these CHECK constraints into account when they are present in
the ``SHOW CREATE TABLE`` output.

Fixes: #4098

Change-Id: I8666d61814e8145ca12cbecad94019b44af868e3
2017-09-28 19:22:17 -04:00
Mike Bayer 35a1f5481a Make a common approach for "emulated" types
Internal refinements to the :class:`.Enum`, :class:`.Interval`, and
:class:`.Boolean` types, which now extend a common mixin
:class:`.Emulated` that indicates a type that provides Python-side
emulation of a DB native type, switching out to the DB native type when a
supporting backend is in use.   The Postgresql :class:`.INTERVAL` type
when used directly will now include the correct type coercion rules for
SQL expressions that also take effect for :class:`.sqltypes.Interval`
(such as adding a date to an interval yields a datetime).

Change-Id: Ifb9f9d7cbd9f5990dcb2abb583193e9e92b789ad
Fixes: #4088
2017-09-25 19:30:51 -04:00
Mike Bayer 70be7312f1 Rename MySQL dml.insert().values to .inserted
Changed the name of the ``.values`` attribute of the new MySQL
INSERT..ON DUPLICATE KEY UPDATE construct to ``.inserted``, as
:class:`.Insert` already has a method called :meth:`.Insert.values`.
The ``.inserted`` attribute ultimately renders the MySQL ``VALUES()``
function.

Change-Id: I8da8e30a3077698385a4b77e2c2032e2d1ff10b2
Fixes: #4072
2017-09-08 21:41:13 -04:00
Mike Bayer 2392ae1900 Apply percent sign escaping to literal binds, comments
Fixed bug in new percent-sign support (e.g. 🎫`3740`) where a bound
parameter rendered with literal_binds would fail to escape percent-signs
for relevant dialects.  In addition, ensured new table / column comment
support feature also fully makes use of literal-rendered parameters so that
this percent sign support takes place with table / column comment DDL as
well, allowing percent sign support for the mysql / psycopg2 backends that
require escaping of percent signs.

Change-Id: Ia4136a300933e9bc6a01a7b9afd5c7b9a3fee4e3
Fixes: #4054
Fixes: #4052
2017-08-25 16:53:49 -04:00
Mike Bayer 63d47c051d - this test doesn't work in strict mode, not that important
Change-Id: I3ed361af5c9f0c7acbeb8b534966828949f4958b
2017-08-20 23:11:57 -04:00
Michael Doronin 7d3da6f850 Implement MySQL's ON DUPLICATE KEY UPDATE
Added support for MySQL's ON DUPLICATE KEY UPDATE
MySQL-specific :class:`.mysql.dml.Insert` object.
Pull request courtesy Michael Doronin.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Resolves: #4009
Change-Id: Ic71424f3c88af6082b48a910a2efb7fbfc0a7eb4
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/365
2017-07-03 14:38:09 -04:00
Mike Bayer 5650a0c306 Handle SHOW VARIABLES returning no row
MySQL 5.7 has introduced permission limiting for the "SHOW VARIABLES"
command; the MySQL dialect will now handle when SHOW returns no
row, in particular for the initial fetch of SQL_MODE, and will
emit a warning that user permissions should be modified to allow the
row to be present.

Change-Id: I98e7a69230da397b17eae07b7e9d024fa7aeeb26
Fixes: #4007
2017-06-16 15:52:46 -04:00
Mike Bayer 9f0fb6c601 Allow metadata.reflect() to recover from unreflectable tables
Added support for views that are unreflectable due to stale
table definitions, when calling :meth:`.MetaData.reflect`; a warning
is emitted for the table that cannot respond to ``DESCRIBE``
but the operation succeeds.  The MySQL dialect now
raises UnreflectableTableError which is in turn caught by
MetaData.reflect().  Reflecting the view standalone raises
this error directly.

Change-Id: Id8005219d8e073c154cc84a873df911b4a6cf4d6
Fixes: #3871
2017-05-22 15:51:07 -04:00
Mike Bayer c0b85ad6ad Remove MySQL UTC_TIMESTAMP rule
Removed an ancient and unnecessary intercept of the UTC_TIMESTAMP
MySQL function, which was getting in the way of using it with a
parameter.

Change-Id: I6e6b52c051418bcb9d31987e78299310810cb78d
Fixes: #3966
2017-04-13 10:11:41 -04:00
Mike Bayer 93b11905e5 Consider mysql partition options separately from other table options
Move down all the PARTITION, SUBPARTITION options
into a separate segment so that they come out at the
end of CREATE TABLE after the table options.

Change-Id: Iaa1c823848c93680ca22d72bda1b7c49742b9060
Fixes: #3961
2017-04-06 12:12:26 -04:00
Mike Bayer f107dd78ec - limit to MySQL dialect
Change-Id: I2781e1e2221d89c75dd65ff49490d9c409967930
2017-02-13 14:40:55 -05:00
Mike Bayer 4e54f9fc07 - pull autocommit suite into the mysql suite as well
Change-Id: If1106f7f125739e69ad2482f65b8f37672a76c9e
2017-02-13 14:33:21 -05:00
Khairi Hafsham 772374735d Make all tests to be PEP8 compliant
tested using pycodestyle version 2.2.0

Fixes: #3885
Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
2017-02-07 11:21:56 -05:00
mike bayer 99d65925e6 Merge "Parse (but don't record) COMMENT portion of MySQL table key" 2017-01-17 10:47:33 -05:00
Lele Long bd6ba3ac82 Parse (but don't record) COMMENT portion of MySQL table key
The MySQL dialect now will not warn when a reflected column has a
"COMMENT" keyword on it, but note however the comment is not yet
reflected; this is on the roadmap for a future release.  Pull request
courtesy Lele Long.

Fixes: #3867
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/324
Change-Id: I869e29aba6766d0eda1e59af09a3e8e3748a3942
2017-01-17 10:23:07 -05:00
Joseph Schorr 1f407c2a47 Add support for prefixes on CREATE INDEX statements in MySQL
Added a new parameter ``mysql_prefix`` supported by the :class:`.Index`
construct, allows specification of MySQL-specific prefixes such as
"FULLTEXT". Pull request courtesy Joseph Schorr.

Change-Id: I5a21fa466fdfd4d9e39e1fb4ecec1eab93b92c36
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/339
2017-01-17 10:21:47 -05:00
Mike Bayer dd4e09d387 Add check for blank string coming from MySQL's enum
MySQL's native ENUM type supports any non-valid value being sent, and
in response will return a blank string.  A hardcoded rule to check for
"is returning the blank string" has been added to the  MySQL
implementation for ENUM so that this blank string is returned to the
application rather than being rejected as a non-valid value.  Note that
if your MySQL enum is linking values to objects, you still get the
blank string back.

Change-Id: I61f85c20293a48b0c11a31f2a19f6756c206bd20
Fixes: #3841
2016-10-28 14:17:40 -04:00
Mike Bayer af6f4ab938 Propagate kwargs to all MySQL CAST paths
Change-Id: I23a6abb26bbbe3d118887d043ce761fc4572d8d2
Fixes: #3766
2016-08-04 12:34:55 -04:00
Mike Bayer 02190234a2 - a variety of test adjustments to accomodate for MySQL 5.7
Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387
2016-07-24 16:36:27 -04:00
Mike Bayer 91a1022227 Disable Enum string validation by default
Rolled back the validation rules a bit in :class:`.Enum` to allow
unknown string values to pass through, unless the flag
``validate_string=True`` is passed to the Enum; any other kind of object is
still of course rejected.  While the immediate use
is to allow comparisons to enums with LIKE, the fact that this
use exists indicates there may be more unknown-string-comparsion use
cases than we expected, which hints that perhaps there are some
unknown string-INSERT cases too.

Change-Id: I7d1d79b374a7d47966d410998f77cd19294ab7b0
Fixes: #3725
2016-06-20 11:45:24 -04:00
Mike Bayer d619191180 - Added support for rendering "FULL OUTER JOIN" to both Core and ORM.
Pull request courtesy Stefan Urbanek.  fixes #1957
2016-03-28 11:50:09 -04:00
Mike Bayer 31f96c27a5 - changelog and docs for #3332, fixes #3332
- make docs for isolation level more consistent between postgresql
and mysql
- move mysql autocommit tests
2016-03-15 17:17:21 -04:00
Mike Bayer 224b03f9c0 Merge branch 'master' into pr157 2016-03-15 16:41:17 -04:00
Mike Bayer df55695f8e - add changelog and migration notes for new Enum features,
fixes #3095, #3292
- reorganize enum constructor to again work with the MySQL
ENUM type
- add a new create_constraint flag to Enum to complement that of
Boolean
- reinstate the CHECK constraint tests for enum, these already
fail /skip against the MySQL backend
- simplify lookup rules in Enum, have them apply to all varieties
of Enum equally
2016-02-02 15:04:46 -05:00
Mike Bayer 269313218d - move out match compiler test to test_compiler
- test_query isn't assertscompiledsql
2016-01-23 14:29:25 -05:00
Mike Bayer 93d71b80f2 - add a few JSON tests specific to MySQL, including basic reflection 2016-01-06 13:18:04 -05:00
Mike Bayer 04b1a52783 - break out mysql/base into modules as it's getting huge with more to come 2016-01-04 17:37:23 -05:00
Mike Bayer 8c54b14b5c - An adjustment to the regular expression used to parse MySQL views,
such that we no longer assume the "ALGORITHM" keyword is present in
the reflected view source, as some users have reported this not being
present in some Amazon RDS environments.
fixes #3613
2015-12-22 12:04:45 -05:00
Mike Bayer f4a1129e79 - fix changelog for #3602
- add version switch for backend fsp test

(cherry picked from commit 67b22cee3a)
2015-12-08 13:50:25 -05:00
Mike Bayer 7df4054b04 - make this DROP conditional, attempting to isolate why jenkins has
an issue with just one test
2015-12-08 10:40:45 -05:00
Mike Bayer 3f42743d6a - Fixed bug in MySQL reflection where the "fractional sections portion"
of the :class:`.mysql.DATETIME`, :class:`.mysql.TIMESTAMP` and
:class:`.mysql.TIME` types would be incorrectly placed into the
``timestamp`` attribute, which is unused by MySQL, instead of the
``fsp`` attribute.
fixes #3602
2015-12-07 17:24:09 -05:00
Mike Bayer d7eae8c95c - flake8 test_reflection and rework the type-based tests into
individual categories w/ modernized fixtures, assert attributes
within type objects.
2015-12-07 17:09:11 -05:00
Mike Bayer 414af7b612 - The system by which a :class:.Column considers itself to be an
"auto increment" column has been changed, such that autoincrement
is no longer implicitly enabled for a :class:`.Table` that has a
composite primary key.  In order to accommodate being able to enable
autoincrement for a composite PK member column while at the same time
maintaining SQLAlchemy's long standing behavior of enabling
implicit autoincrement for a single integer primary key, a third
state has been added to the :paramref:`.Column.autoincrement` parameter
``"auto"``, which is now the default. fixes #3216
- The MySQL dialect no longer generates an extra "KEY" directive when
generating CREATE TABLE DDL for a table using InnoDB with a
composite primary key with AUTO_INCREMENT on a column that isn't the
first column;  to overcome InnoDB's limitation here, the PRIMARY KEY
constraint is now generated with the AUTO_INCREMENT column placed
first in the list of columns.
2015-10-07 10:02:45 -04:00
Mike Bayer 7024745a14 - build out a new base type for Array, as well as new any/all operators
- any/all work for Array as well as subqueries, accepted by MySQL
- Postgresql ARRAY now subclasses Array
- fixes #3516
2015-08-25 18:24:46 -04:00
Mike Bayer 9a4a8a8684 - totally skip on mysqlconnector for now 2015-03-21 15:14:47 -04:00
Mike Bayer 10593e7768 - oursql is unsupported on this 2015-03-21 09:57:01 -04:00
Mike Bayer 3ae00fea90 - Repaired the commit for issue #2771 which was inadvertently commented
out.
- add __backend__ to the dialect suite so that it runs on CI.
- will be 1.0.0b3
2015-03-20 19:53:12 -04:00
Mike Bayer e429f9ebe7 - test fix 2015-03-20 16:07:09 -04:00
Mike Bayer 58ce4d53bf - add a test for #2771, fixes #2771
- changelog for #2771
2015-03-20 15:08:23 -04:00
Roman Podoliaka a87b3c2101 Add 'native' autocommit support for mysql drivers
Sometimes it might be useful to have 'native' autocommit support
provided by a DB API driver rather than rely on SQLAlchemy autocommit
emulation.
2015-02-24 19:50:54 +02:00
Mike Bayer 3c46eb17ed - additional mysql cast-related test fixes 2015-02-09 20:49:19 -05:00
Mike Bayer af42398742 - The MySQL dialect now supports CAST on types that are constructed
as :class:`.TypeDecorator` objects.
2015-02-09 20:43:28 -05:00
Mike Bayer 1ad236127c - A warning is emitted when :func:.cast is used with the MySQL
dialect on a type where MySQL does not support CAST; MySQL only
supports CAST on a subset of datatypes.   SQLAlchemy has for a long
time just omitted the CAST for unsupported types in the case of
MySQL.  While we don't want to change this now, we emit a warning
to show that it's taken place.   A warning is also emitted when
a CAST is used with an older MySQL version (< 4) that doesn't support
CAST at all, it's skipped in this case as well.
fixes #3237
2015-02-09 15:29:14 -05:00
Mike Bayer 03038f7e75 - flake8 2015-02-09 15:08:52 -05:00
Mike Bayer a14729266a - make even more tables 2015-02-07 10:22:08 -05:00
Mike Bayer 68900c2654 - break up the tables here to avoid the error we're getting
on jenkins
2015-02-06 23:41:01 -05:00
Mike Bayer 503a40ad70 - The MySQL dialect now renders TIMESTAMP with NULL / NOT NULL in
all cases, so that MySQL 5.6.6 with the
``explicit_defaults_for_timestamp`` flag enabled will
will allow TIMESTAMP to continue to work as expected when
``nullable=False``.  Existing applications are unaffected as
SQLAlchemy has always emitted NULL for a TIMESTAMP column that
is ``nullable=True``.  fixes #3155
2015-02-05 16:24:45 -05:00
Mike Bayer a324164933 - this is passing, no idea why 2015-01-04 21:05:53 -05:00