Commit Graph

625 Commits

Author SHA1 Message Date
Mike Bayer a552606091 - Added new MySQL-specific :class:.mysql.DATETIME which includes
fractional seconds support; also added fractional seconds support
to :class:`.mysql.TIMESTAMP`.  DBAPI support is limited, though
fractional seconds are known to be supported by MySQL Connector/Python.
Patch courtesy Geert JM Vanderkelen. #2941
2014-02-19 15:49:37 -05:00
Mike Bayer 7e66d7e392 Merge branch 'master' of https://bitbucket.org/50onred/sqlalchemy/overview into t 2014-02-19 15:24:36 -05:00
Mike Bayer ecdfc31774 - Support has been improved for Postgresql reflection behavior on very old
(pre 8.1) versions of Postgresql, and potentially other PG engines
such as Redshift (assuming Redshift reports the version as < 8.1).
The query for "indexes" as well as "primary keys" relies upon inspecting
a so-called "int2vector" datatype, which refuses to coerce to an array
prior to 8.1 causing failures regarding the "ANY()" operator used
in the query.  Extensive googling has located the very hacky, but
recommended-by-PG-core-developer query to use when PG version < 8.1
is in use, so index and primary key constraint reflection now work
on these versions.
2014-02-18 18:35:23 -05:00
Mike Bayer b4d9795db1 - dont need this import and it's not in 2.6 anyway 2014-02-17 16:03:07 -05:00
Mike Bayer 00c6ebb440 - rewrite SQLite reflection tests into one consistent fixture, which tests
both _resolve_type_affinity() directly as well as round trip tests fully.
2014-02-16 18:14:10 -05:00
Mike Bayer 5e100a70c5 - The SQLite dialect will now skip unsupported arguments when reflecting
types; such as if it encounters a string like ``INTEGER(5)``, the
:class:`.INTEGER` type will be instantiated without the "5" being included,
based on detecting a ``TypeError`` on the first attempt.
2014-02-16 17:20:18 -05:00
Mike Bayer 198a900bd1 Merge branch 'master' of https://github.com/eblume/sqlalchemy into t 2014-02-16 16:43:42 -05:00
Marcus McCurdy c597843f13 Fixes MySQL dialect partitioning 2014-02-14 13:23:51 -05:00
Erich Blume e47f994503 SQLite dialect - support relection from affinity
SQLite allows column types that aren't technically understood in sqlite
by using 'data affinity', which is an algorithm for converting column
types in to some sort of useful type that can be stored and retrieved
from the db. Unfortunatly, this breaks reflection since we (previously)
expected a sqlite db to reflect column types that we permit in the
`ischema_names` for that dialect.

This patch changes the logic for 'unknown' column types during
reflection to instead run through SQLite's data affinity algorithm, and
assigns appropriate types from that.

It also expands the matching for column type to include column types
with spaces (strongly discouraged but allowed by sqlite) and also
completely empty column types (in which case the NullType is assigned,
which sqlite will treat as a Blob - or rather, Blob is treated as
NullType). These changes mean that SQLite will never raise an error for
an unknown type during reflection - there will always be some 'useful'
type returned, which follows the spirit of SQLite (accomodation before
sanity!).
2014-02-03 16:55:00 -08:00
Mike Bayer 0326f3cf01 - Added :paramref:.MetaData.reflect.**dialect_kwargs
to support dialect-level reflection options for all :class:`.Table`
objects reflected.

- Added a new dialect-level argument ``postgresql_ignore_search_path``;
this argument is accepted by both the :class:`.Table` constructor
as well as by the :meth:`.MetaData.reflect` method.  When in use
against Postgresql, a foreign-key referenced table which specifies
a remote schema name will retain that schema name even if the name
is present in the ``search_path``; the default behavior since 0.7.3
has been that schemas present in ``search_path`` would not be copied
to reflected :class:`.ForeignKey` objects.  The documentation has been
updated to describe in detail the behavior of the ``pg_get_constraintdef()``
function and how the ``postgresql_ignore_search_path`` feature essentially
determines if we will honor the schema qualification reported by
this function or not. [ticket:2922]
2014-02-02 16:33:54 -05:00
donkopotamus 3593548960 Support mssql_clustered option on UniqueConstraint (plus docs and test) 2014-01-17 10:46:16 +13:00
donkopotamus 1de7259093 Remove support for mssql_clustered on Table 2014-01-17 10:38:31 +13:00
donkopotamus 40563e9355 Support mssql_clustered option in mssql dialect for both Table and PrimaryKeyConstraint 2014-01-14 12:44:05 +13:00
Mike Bayer 1536bc4664 - The MySQL CAST compilation now takes into account aspects of a string
type such as "charset" and "collation".  While MySQL wants all character-
based CAST calls to use the CHAR type, we now create a real CHAR
object at CAST time and copy over all the parameters it has, so that
an expression like ``cast(x, mysql.TEXT(charset='utf8'))`` will
render ``CAST(t.col AS CHAR CHARACTER SET utf8)``.

- Added new "unicode returns" detection to the MySQL dialect and
to the default dialect system overall, such that any dialect
can add extra "tests" to the on-first-connect "does this DBAPI
return unicode directly?" detection. In this case, we are
adding a check specifically against the "utf8" encoding with
an explicit "utf8_bin" collation type (after checking that
this collation is available) to test for some buggy unicode
behavior observed with MySQLdb version 1.2.3.  While MySQLdb
has resolved this issue as of 1.2.4, the check here should
guard against regressions.  The change also allows the "unicode"
checks to log in the engine logs, which was not previously
the case. [ticket:2906]
2014-01-13 14:05:05 -05:00
Mike Bayer 4b923d37bd - support addition of fails_if()/only_on(), just wraps the decorators
- update a few exclusions to support current pymssql.  passes all of test_suite and dialect/mssql
2014-01-02 14:23:14 -05:00
Mike Bayer 2104d0ba2d - rework the JSON expression system so that "astext" is called *after*
the indexing.  this is for more natural operation.
- also add cast() to the JSON expression to complement astext. This integrates
the CAST call which will be needed frequently.  Part of [ticket:2687].
- it's a little unclear how more advanced unicode attribute-access is going to go,
some quick attempts at testing yielded strange error messages from psycopg2.
- do other cross linking as mentioned in [ticket:2687].
2013-12-27 18:25:57 -05:00
Mike Bayer 92a1426c06 - The firebird dialect will quote identifiers which begin with an
underscore.  Courtesy Treeve Jelbert. [ticket:2897]
2013-12-27 13:40:27 -05:00
mike bayer 69876ada92 Merge pull request #51 from sontek/pymssql_handle_terminated_connection
Remove terminated connections from the pool.
2013-12-27 08:12:05 -08:00
Mike Bayer 5402e2f5dd remove print 2013-12-19 16:07:35 -05:00
Mike Bayer 2692238f45 - Improvements to the system by which SQL types generate within
``__repr__()``, particularly with regards to the MySQL integer/numeric/
character types which feature a wide variety of keyword arguments.
The ``__repr__()`` is important for use with Alembic autogenerate
for when Python code is rendered in a migration script.
[ticket:2893]
2013-12-18 18:26:15 -05:00
Mike Bayer fec03c88d6 - make the json serializer and deserializer per-dialect, so that we are
compatible with psycopg2's per-connection/cursor approach.  add round trip tests for
both native and non-native.
2013-12-17 17:46:09 -05:00
Mike Bayer d98fcca0b3 this test appears to be failing with pg 9.3, not sure how to restore it 2013-12-17 15:37:50 -05:00
Mike Bayer e1802ff542 - using AssertsCompiledSQL so need __dialect__ 2013-12-17 15:33:27 -05:00
Mike Bayer 73013914e7 - rework JSON expressions to be based off __getitem__ exclusively
- add support for "standalone" JSON objects; this involves getting CAST
to upgrade the given type of a bound parameter.  should add a core-only test
for this.
- add tests for "standalone" json round trips both with and without unicode
- add mechanism by which we remove psycopg2's "json" handler in order to get
the effect of using our non-native result handlers
2013-12-17 15:13:39 -05:00
Mike Bayer 2c3afb4dcb Merge branch 'issue_2581' of github.com:nathan-rice/sqlalchemy into pg_json 2013-12-17 14:03:20 -05:00
John Anderson 3147ca3040 Remove terminated connections from the pool.
In pymssql, if you terminate a long running query manually
it will give you a connection reset by peer message, but this
connection remains in the pool and will be re-used.
2013-12-16 12:50:10 -08:00
nathan 015c73c83a sqlalchemy/dialects/postgresql/pgjson:
- Added support for additional operators
 - Made return as json default (rather than text)
2013-12-11 10:21:08 -05:00
nathan f285b3536f sqlalchemy/dialects/postgresql/pgjson:
- Fixed reference to HSTORE
 - Corrected spelling of SQLAlchemy

 sqlalchemy/dialects/postgresql/psycopg2:
 - Added psycopg2 specific wrapper type for JSON which uses inherent json deserialization facilities
 - Added code to detect and utilize the JSON wrapper if psycopg2 >= 2.5

test/dialect/postgresql/test_types:
- removed reference to use_native_hstore
2013-12-10 10:01:51 -05:00
Mike Bayer 164bff0749 - round trip test
- changelog
- some doc rearrangement
2013-12-09 21:27:14 -05:00
Noufal Ibrahim d3b65cd9bc Adds test to verify tsvector creation.
Signed-off-by: Noufal Ibrahim <noufal@nibrahim.net.in>
2013-12-10 01:07:53 +05:30
nathan ba73d619ca Merge branch 'rel_0_9' of https://github.com/nathan-rice/sqlalchemy into rel_0_9 2013-12-09 11:52:23 -05:00
nathan 64288c7d6f sqlalchemy/dialects/postgresql/__init__.py:
- Added import references to JSON class

 sqlalchemy/dialects/postgresql/base.py:
 - Added visitor method for JSON class

 sqlalchemy/dialects/postgresql/pgjson (new):
 - JSON class, supports automatic serialization and deserialization of json data, as well as basic json operators.
2013-12-09 11:46:36 -05:00
Mike Bayer 3621e4b8de - changelog + test for pullreq #7, MSSQL dialect for DROP INDEX 2013-12-05 18:36:59 -05:00
Mike Bayer d52db834a5 - move additional enum compilation tests to postgresql/test_compiler.py 2013-11-30 16:12:20 -05:00
Mike Bayer 66773a8801 - Fixed bug where values within an ENUM weren't escaped for single
quote signs.   Note that this is backwards-incompatible for existing
workarounds that manually escape the single quotes. [ticket:2878]
2013-11-30 13:53:26 -05:00
Mike Bayer 31cecebd48 - add support for specifying tables or entities for "of"
- implement Query with_for_update()
- rework docs and tests
2013-11-28 23:23:27 -05:00
Mike Bayer 4aaf3753d7 - fix up rendering of "of"
- move out tests, dialect specific out of compiler, compiler tests use new API,
legacy API tests in test_selecatble
- add support for adaptation of ForUpdateArg, alias support in compilers
2013-11-28 22:25:09 -05:00
Mike Bayer 69b9f62afc - this test only for mysql 2013-11-23 17:05:45 -05:00
Mike Bayer 6b79d2ea79 - The precision used when coercing a returned floating point value to
Python ``Decimal`` via string is now configurable.  The
flag ``decimal_return_scale`` is now supported by all :class:`.Numeric`
and :class:`.Float` types, which will ensure this many digits are taken
from the native floating point value when it is converted to string.
If not present, the type will make use of the value of ``.scale``, if
the type supports this setting and it is non-None.  Otherwise the original
default length of 10 is used. [ticket:2867]
2013-11-22 20:04:19 -05:00
Mike Bayer 467784e89c Fixed bug where Oracle `VARCHAR` types given with no length
(e.g. for a ``CAST`` or similar) would incorrectly render ``None CHAR``
or similar. [ticket:2870]
2013-11-22 17:56:35 -05:00
Mike Bayer 6661cba88d - cleanup 2013-11-22 17:48:55 -05:00
Mike Bayer 59ca4633ac - remove informix dialect, moved out to https://bitbucket.org/zzzeek/sqlalchemy_informixdb
- remove informix, maxdb, access symbols from tests etc.
2013-11-17 13:45:23 -05:00
Mike Bayer 5070c81ab9 - Fixed bug where Oracle table reflection using synonyms would fail
if the synonym and the table were in different remote schemas.
Patch to fix courtesy Kyle Derr. [ticket:2853]
2013-10-25 19:11:53 -04:00
Mike Bayer 46ac022e57 - move this test to PG test_reflection
- don't use locals()
2013-10-25 17:19:03 -04:00
Mike Bayer 51e8e5df46 - Fix and test parsing of MySQL foreign key options within reflection;
this complements the work in 🎫`2183` where we begin to support
reflection of foreign key options such as ON UPDATE/ON DELETE
cascade. [ticket:2839]
2013-10-25 17:18:40 -04:00
Mike Bayer e5a42a748b Merge branch 'master' of github.com:ijl/sqlalchemy into merge_2183 2013-10-25 17:01:38 -04:00
Mike Bayer fff9079909 - Removed a 128-character truncation from the reflection of the
server default for a column; this code was original from
PG system views which truncated the string for readability.
[ticket:2844]
2013-10-18 19:00:05 -04:00
Mike Bayer ca02882c6a - The change in 🎫2721, which is that the `deferrable` keyword
of :class:`.ForeignKeyConstraint` is silently ignored on the MySQL
backend, will be reverted as of 0.9; this keyword will now render again, raising
errors on MySQL as it is not understood - the same behavior will also
apply to the ``initially`` keyword.  In 0.8, the keywords will remain
ignored but a warning is emitted.   Additionally, the ``match`` keyword
now raises a :class:`.CompileError` on 0.9 and emits a warning on 0.8;
this keyword is not only silently ignored by MySQL but also breaks
the ON UPDATE/ON DELETE options.

To use a :class:`.ForeignKeyConstraint`
that does not render or renders differently on MySQL, use a custom
compilation option.  An example of this usage has been added to the
documentation, see :ref:`mysql_foreign_keys`.
[ticket:2721] [ticket:2839]
2013-10-18 14:44:01 -04:00
Mike Bayer a5dc173ea6 - Added support for rendering `SMALLSERIAL when a :class:.SmallInteger`
type is used on a primary key autoincrement column, based on server
version detection of Postgresql version 9.2 or greater.
[ticket:2840]
2013-10-15 19:06:21 -04:00
Mike Bayer 92534dc8f3 The MySQL :class:.mysql.SET type now features the same auto-quoting
behavior as that of :class:`.mysql.ENUM`.  Quotes are not required when
setting up the value, but quotes that are present will be auto-detected
along with a warning.  This also helps with Alembic where
the SET type doesn't render with quotes. [ticket:2817]
2013-10-14 16:12:54 -04:00