Commit Graph

70 Commits

Author SHA1 Message Date
David Moore acabfc72ad Add support for CACHE and ORDER to sequences
Added new keywords :paramref:`.Sequence.cache` and
:paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering
of the CACHE parameter understood by Oracle and PostgreSQL, and the
ORDER parameter understood by Oracle.  Pull request
courtesy David Moore.

Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
(cherry picked from commit faa6609dac)
2017-07-05 16:23:13 -04: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 8a13957db7 Change autoincrement compileerror to a warning
Users are complaining that IntegrityError is no longer
raised.

Change-Id: I0855d5b7a98d4338f0910501b6e6d404ba33634d
Fixes: #3216
2016-10-07 09:54:39 -04:00
Mike Bayer 079df65dc0 Escape literal string values passed to server_default
A string sent as a column default via the
:paramref:`.Column.server_default` parameter is now escaped for quotes.

This change is backwards compatible with code that may have been
working around this previously.

Change-Id: I341298a76cc67bc0a53df4ab51ab9379f2294cdd
Fixes: #3809
2016-09-30 09:23:50 -04:00
Mike Bayer e486ef666f Work w/ prefetch even for selects, if present
Fixed bug in new CTE feature for update/insert/delete stated
as a CTE inside of an enclosing statement (typically SELECT) whereby
oninsert and onupdate values weren't called upon for the embedded
statement.

This is accomplished by consulting prefetch
for all statements.  The collection is also broken into
separate insert/update collections so that we don't need to
consult toplevel self.isinsert to determine if the prefetch
is for an insert or an update.  What we don't yet test for
are CTE combinations that have both insert/update in one
statement, though these should now work in theory provided
the underlying database supports such a statement.

Change-Id: I3b6a860e22c86743c91c56a7ec751ff706f66f64
Fixes: #3745
2016-07-12 16:43:49 -04:00
Mike Bayer f38f890849 Deprecate FromClause.count()
count() here is misleading in that it not only
counts from an arbitrary column in the table, it also
does not make accommodations for DISTINCT, JOIN, etc.
as the ORM-level function does.  Core should not be
attempting to provide a function like this.

Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2
Fixes: #3724
2016-06-14 11:48:04 -04:00
Mike Bayer 382950b701 Merge branch 'pr204' 2015-10-29 14:38:34 -04:00
Mike Bayer e31211c578 - convert wrap_callable() to a general purpose update_wrapper-like
function; the caller still passes in the "wrapper"
- move tests for wrap_callable() to be generic util tests
- changelog for pullreq github:204
2015-10-29 14:28:00 -04:00
Martin J. Hsu c7d04beeac - wrap ColumnDefault empty arg callables like functools.wraps, setting __name__, __doc__, and __module__ 2015-10-15 10:46:33 +08:00
Mike Bayer a47e863dc5 - this was supposed to be client-side SQL default not server side 2015-10-09 17:10:08 -04:00
Mike Bayer 845500280d - open up autoincrement for columns that have a default; autoinc is usually
"auto" now so True can indicate the dialect would support this
2015-10-08 17:02:55 -04: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 c39ff9978d - Fixed regression in 1.0-released default-processor for multi-VALUES
insert statement, 🎫`3288`, where the column type for the
default-holding column would not be propagated to the compiled
statement in the case where the default was being used,
leading to bind-level type handlers not being invoked.
fixes #3520
2015-08-31 11:30:03 -04:00
Mike Bayer 480dad983c - fix these two tests 2015-07-17 11:08:42 -04:00
jakeogh 66b9a71ce7 add CYCLE support to Sequence() and docstrings for NO MINVALUE and NO MAXVALUE 2015-06-27 20:49:46 +00:00
jakeogh 85ebe01349 add NO MINVALUE and NO MAXVALUE support to Sequence() 2015-06-27 18:48:46 +00:00
jakeogh ad7caa6988 add MAXVALUE support to Sequence() 2015-06-27 18:37:09 +00:00
jakeogh f31c288b65 add MINVALUE support to Sequence() 2015-06-27 08:40:44 +00:00
Mike Bayer b3d3795de0 - The SQL compiler now generates the mapping of expected columns
such that they are matched to the received result set positionally,
rather than by name.  Originally, this was seen as a way to handle
cases where we had columns returned with difficult-to-predict names,
though in modern use that issue has been overcome by anonymous
labeling.   In this version, the approach basically reduces function
call count per-result by a few dozen calls, or more for larger
sets of result columns.  The approach still degrades into a modern
version of the old approach if textual elements modify the result
map, or if any discrepancy in size exists between
the compiled set of columns versus what was received, so there's no
issue for partially or fully textual compilation scenarios where these
lists might not line up.  fixes #918
- callcounts still need to be adjusted down for this so zoomark
tests won't pass at the moment
2015-03-07 17:18:31 -05:00
Mike Bayer 81aa5b376e - Literal values within a :class:.DefaultClause, which is invoked
when using the :paramref:`.Column.server_default` parameter, will
now be rendered using the "inline" compiler, so that they are rendered
as-is, rather than as bound parameters.
fixes #3087
2015-02-09 14:58:26 -05:00
Mike Bayer 62f8774906 - fix this test for py3k 2015-01-26 22:45:12 -05:00
Mike Bayer 0e6579bc62 Merge remote-tracking branch 'origin/pr/150' 2015-01-26 16:49:43 -05:00
Mike Bayer 92cc232726 - The multi-values version of :meth:.Insert.values has been
repaired to work more usefully with tables that have Python-
side default values and/or functions, as well as server-side
defaults. The feature will now work with a dialect that uses
"positional" parameters; a Python callable will also be
invoked individually for each row just as is the case with an
"executemany" style invocation; a server- side default column
will no longer implicitly receive the value explicitly
specified for the first row, instead refusing to invoke
without an explicit value. fixes #3288
2015-01-13 14:33:33 -05:00
Ryan P. Kelly 9fb6acad67 Report the type of unexpected expression objects 2014-11-20 14:40:32 -05:00
Mike Bayer 95be42c06f - :meth:.Insert.from_select now includes Python and SQL-expression
defaults if otherwise unspecified; the limitation where non-
server column defaults aren't included in an INSERT FROM
SELECT is now lifted and these expressions are rendered as
constants into the SELECT statement.
2014-10-10 17:15:19 -04:00
Mike Bayer d7131ffad3 - optional 'b' here for py3k 2014-08-31 18:02:24 -04:00
Mike Bayer 3c60d3b1ca - A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string.   This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.
fixes #3178
2014-08-31 15:22:00 -04:00
Mike Bayer bb5f4392a4 - update the flake8 rules again
- apply autopep8 + manual fixes to most of test/sql/
2014-07-18 17:40:58 -04:00
Tony Locke fa80b73e3c PEP8 tidy of subset of test/sql/*.py 2014-07-07 07:32:33 +01:00
Tony Locke 73d00339c4 pg8000 passing test/sql 2014-07-06 23:13:44 +01:00
Mike Bayer 2f150bee28 - rename __multiple__ to __backend__, and apply __backend__ to a large number of tests.
- move out logging tests from test_execute to test_logging
2014-03-24 11:33:53 -04:00
Mike Bayer 65bd6ec966 - Fixed issue where a primary key column that has a Sequence on it,
yet the column is not the "auto increment" column, either because
it has a foreign key constraint or ``autoincrement=False`` set,
would attempt to fire the Sequence on INSERT for backends that don't
support sequences, when presented with an INSERT missing the primary
key value.  This would take place on non-sequence backends like
SQLite, MySQL. [ticket:2896]
2013-12-20 10:26:09 -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 1f1ad557af The `default argument of :class:.Column` now accepts a class
or object method as an argument, in addition to a standalone function;
will properly detect if the "context" argument is accepted or not.
2013-10-11 16:16:08 -04:00
Mike Bayer cca97433c1 merge default 2013-05-05 01:42:26 -04:00
Mike Bayer afcbd7419c and int types here... 2013-05-04 15:10:41 -04:00
Mike Bayer 2a8fcfaa42 update test 2013-05-04 15:09:04 -04:00
Mike Bayer ee9723d7d7 cleanup 2013-05-04 15:08:08 -04:00
Mike Bayer 9db36c36aa cleanup and formatting 2013-05-04 15:06:47 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer 1a7778632d - further reorganization of test suite:
- bootstrap and lib move to all absolute imports
  - testing.py is no longer internally referenced.
  - requirements move to be a pluggable class which can
    be overridden.
  - cleanup

in the interests of third party testing, test/lib and test/bootstrap
may move to be an independent package.
2012-09-26 17:21:21 -04:00
Mike Bayer 626ae5b7a1 - fixes for mxODBC, some pyodbc
- enhancements to test suite including ability to set up a testing engine
for a whole test class, fixes to how noseplugin sets up/tears
down per-class context
2012-09-02 15:14:09 -04:00
Mike Bayer ce1b80ad08 - [bug] Fixes to the interpretation of the
Column "default" parameter as a callable
to not pass ExecutionContext into a keyword
argument parameter.  [ticket:2520]
2012-08-20 13:20:09 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04:00
Mike Bayer 042184fdc9 add a checkfirst here as s3 seems to be stuck on the jenkins db 2012-03-14 16:25:57 -07:00
Mike Bayer c718ad227e tests for FK/autoincrement selection 2011-12-06 22:00:35 -05:00
Mike Bayer 9ae8de1f65 - Fixed bug where "autoincrement" detection on
Table would fail if the type had no "affinity"
value, in particular this would occur when using
the UUID example on the site that uses TypeEngine
as the "impl".
2011-06-30 18:48:01 -04:00
Mike Bayer 1dcf33e712 fix some tests 2011-06-02 03:09:08 -04:00
Mike Bayer 7b24e458c7 - move all the comments that got shoved below the fixture grabs back up 2011-03-27 17:19:00 -04:00