Commit Graph

508 Commits

Author SHA1 Message Date
Mike Bayer 1b16954864 - introduce an optimizing type _NativeUnicodeMixin to oracle plus supporting
changes to Enum/SchemaType to re-support adaptation of string types.
This approach can be adapted by "conditional" unicode returning dialects
(i.e. pyodbc and possibly mxodbc) to remove the overhead
of isinstance(value, unicode) calls when the dialect returned type is
of dbapi.UNICODE, dbapi.NVARCHAR, etc.
2010-03-12 18:30:38 +00:00
Mike Bayer b4f1fbc708 think I came across a syntactical weirdism there 2010-03-11 22:38:15 -05:00
Mike Bayer e66ca9edd5 adding windows-appropriate levels of pain to unicode handling 2010-03-11 22:10:25 -05:00
Mike Bayer 7c8942d4eb Added a non-freetds specific exclusion for pyodbc 2010-03-11 21:23:25 -05:00
Mike Bayer 30327525de this resolves the returning failures from #1733 2010-03-11 21:36:03 +00:00
Mike Bayer b763015642 re-enable these tests 2010-03-11 21:34:13 +00:00
Mike Bayer ec0fafc7b0 added better typing for integer expressions, since integer is implementing _DateAffinity 2010-03-11 16:18:37 -05:00
Mike Bayer 3254699f85 force an oracle test to pass. this is as usual an extremely fringy test for a feature nobody should be using normally. 2010-03-11 18:52:02 +00:00
Mike Bayer ee8eea4101 these fail for unknown reasons. Seems to be potentially VARCHAR used with RETURNING, or out params, not sure. 2010-03-11 18:39:15 +00:00
Mike Bayer 47f7b6f68e fix this test for oracle so all types return datetime.date 2010-03-11 18:34:27 +00:00
Mike Bayer 9a3a909ed2 this test requires a length for the varchar in mysql/oracle 2010-03-11 18:21:44 +00:00
Mike Bayer 86df449c2b - fixed internal error which would occur if calling has()
or similar complex expression on a single-table inheritance
relation(). [ticket:1731]
2010-03-11 12:07:08 -05:00
Mike Bayer 969c04860f almost there, some tests failing still. 2010-03-09 13:41:43 -05:00
Mike Bayer c3fd9a5536 still thinking about stuff here 2010-03-08 21:15:16 -05:00
Mike Bayer b9cc0ef326 working on getting operators/left hand type awareness into the "bind" coercion. this system has to be figured out somehow 2010-03-08 18:27:35 -05:00
Mike Bayer da1666cc18 - adjusted the literal coercion rules to take the left side's type into account, if it is
compatible with what was found for the right, so that things like oracle CHAR conversions
work.
- oracle dialect specific tests pass again.
2010-03-01 01:00:12 +00:00
Mike Bayer a76927f584 - the execution sequence pulls all rowcount/last inserted ID
info from the cursor before commit() is called on the
DBAPI connection in an "autocommit" scenario.  This helps
mxodbc with rowcount and is probably a good idea overall.
- cx_oracle wants list(), not tuple(), for empty execute.
- cleaned up plain SQL param handling
2010-02-28 23:51:54 +00:00
Mike Bayer cd6af2e03b working on pyodbc / mxodbc 2010-02-27 20:03:33 +00:00
Mike Bayer 46fa536ba4 - threadlocal engine wasn't properly closing the connection
upon close() - fixed that.
- Transaction object doesn't rollback or commit if it isn't
"active", allows more accurate nesting of begin/rollback/commit.
- Added basic support for mxODBC [ticket:1710].
- Python unicode objects as binds result in the Unicode type,
not string, thus eliminating a certain class of unicode errors
on drivers that don't support unicode binds.
2010-02-27 00:44:26 +00:00
Mike Bayer 2d95ef1f25 - the "scale" argument of the Numeric() type is honored when
coercing a returned floating point value into a string
on its way to Decimal - this allows accuracy to function
on SQLite, MySQL.  [ticket:1717]
2010-02-26 17:50:34 +00:00
Mike Bayer 060e301183 - walk back r6851 slightly. Still emit a warning when the Unicode or UnicodeText type
is passed a bytestring even if the backend accepts unicodes directly.
2010-02-25 22:16:34 +00:00
Mike Bayer 756370e0b4 - The assert_unicode flag is deprecated. SQLAlchemy will raise
a warning in all cases where it is asked to encode a non-unicode
Python string, and will do nothing for DBAPIs that already
accept Python unicode objects.
2010-02-25 22:00:58 +00:00
Michael Trier 8056006f06 Support for the mysql+oursql dialect. Thank you Taavi Burns. 2010-02-25 10:07:59 +00:00
Mike Bayer 2aa9f5541b - "out" parameters require a type that is supported by
cx_oracle.  An error will be raised if no cx_oracle
type can be found.
- Column() requires a type if it has no foreign keys (this is
not new).  An error is now raised if a Column() has no type
and no foreign keys.  [ticket:1705]
2010-02-23 22:15:09 +00:00
Mike Bayer 189414fe29 add some py3k caveats 2010-02-23 21:38:39 +00:00
Mike Bayer 05d5fc11d9 - Added "unicode_errors" parameter to String, Unicode, etc.
Behaves like the 'errors' keyword argument to
the standard library's string.decode() functions.   This flag
requires that `convert_unicode` is set to `"force"` - otherwise,
SQLAlchemy is not guaranteed to handle the task of unicode
conversion.   Note that this flag adds significant performance
overhead to row-fetching operations for backends that already
return unicode objects natively (which most DBAPIs do).  This
flag should only be used as an absolute last resort for reading
strings from a column with varied or corrupted encodings,
which only applies to databases that accept invalid encodings
in the first place (i.e. MySQL. *not* PG, Sqlite, etc.)
2010-02-23 19:53:07 +00:00
Mike Bayer c8e8d77fdc - added util.portable_instancemethod to provide a quick way to make an instancemethod "serializable"
- SchemaType and subclasses Boolean, Enum are now serializable,
including their ddl listener and other event callables.
[ticket:1694] [ticket:1698]
- AddConstraint/DropConstraint use the wrapper for _create_rule
- added test coverage for AddConstraint override of _create_rule
2010-02-22 20:37:44 +00:00
Michael Trier 055ac80eb2 Fixed native unicode test to work with pypostgresql. 2010-02-22 19:03:44 +00:00
Mike Bayer ebe7f7b15e - A change to the solution for [ticket:1579] - an end-user
defined bind parameter name that directly conflicts with
a column-named bind generated directly from the SET or
VALUES clause of an update/insert generates a compile error.
This reduces call counts and eliminates some cases where
undesirable name conflicts could still occur.
2010-02-16 19:47:54 +00:00
Mike Bayer 6a935a0e27 - Further fixes for the mysql-connector dialect. [ticket:1668] 2010-02-14 20:24:15 +00:00
Gaëtan de Menten 165609a190 - Added an optional C extension to speed up the sql layer by
reimplementing the highest impact functions.
  The actual speedups will depend heavily on your DBAPI and
  the mix of datatypes used in your tables, and can vary from
  a 50% improvement to more than 200%. It also provides a modest
  (~20%) indirect improvement to ORM speed for large queries.
  Note that it is *not* built/installed by default.
  See README for installation instructions.

- The most common result processors conversion function were
  moved to the new "processors" module.  Dialect authors are
  encouraged to use those functions whenever they correspond
  to their needs instead of implementing custom ones.
2010-02-13 22:53:39 +00:00
Mike Bayer d0d5f79240 - Made sqlalchemy.sql.expressions.Executable part of public
API, used for any expression construct that can be sent to
    execute().  FunctionElement now inherits Executable so that
    it gains execution_options(), which are also propagated
    to the select() that's generated within execute().
    Executable in turn subclasses _Generative which marks
    any ClauseElement that supports the @_generative
    decorator - these may also become "public" for the benefit
    of the compiler extension at some point.
2010-02-12 19:54:49 +00:00
Mike Bayer 85d335b01b - The type/expression system now does a more complete job
of determining the return type from an expression
as well as the adaptation of the Python operator into
a SQL operator, based on the full left/right/operator
of the given expression.  In particular
the date/time/interval system created for Postgresql
EXTRACT in [ticket:1647] has now been generalized into
the type system.   The previous behavior which often
occured of an expression "column + literal" forcing
the type of "literal" to be the same as that of "column"
will now usually not occur - the type of
"literal" is first derived from the Python type of the
literal, assuming standard native Python types + date
types, before falling back to that of the known type
on the other side of the expression.  Also part
of [ticket:1683].
2010-02-11 19:33:06 +00:00
Mike Bayer 2d03b08483 - Restored the keys() method to ResultProxy. 2010-02-10 14:55:37 +00:00
Mike Bayer 1c73149d5d - FunctionElement subclasses are now directly executable the
same way any func.foo() construct is, with automatic
SELECT being applied when passed to execute().

- The "type" and "bind" keyword arguments of a func.foo()
construct are now local to "func." constructs and are
not part of the FunctionElement base class, allowing
a "type" to be handled in a custom constructor or
class-level variable.
2010-02-07 00:56:05 +00:00
Mike Bayer a4a38a982a - Added math negation operator support, -x. 2010-02-05 15:49:02 +00:00
Mike Bayer d1916eb6c9 - allow exists(s.as_scalar()) to work 2010-01-28 21:13:38 +00:00
Mike Bayer 0ca4107c3e add an informative error msg for non-collection passed to select() 2010-01-28 20:30:42 +00:00
Philip Jenvey 8d22a984be oracle compat 2010-01-26 06:17:02 +00:00
Mike Bayer 73bfc87669 - Added a tuple_() construct, allows sets of expressions
to be compared to another set, typically with IN against
composite primary keys or similar.  Also accepts an
IN with multiple columns.   The "scalar select can
have only one column" error message is removed - will
rely upon the database to report problems with
col mismatch.
2010-01-25 21:04:50 +00:00
Mike Bayer 67e7f45c59 - union(), intersect(), except() and other "compound" types
of statements have more consistent behavior w.r.t.
parenthesizing.   Each compound element embedded within
another will now be grouped with parenthesis - previously,
the first compound element in the list would not be grouped,
as SQLite doesn't like a statement to start with
parenthesis.   However, Postgresql in particular has
precedence rules regarding INTERSECT, and it is
more consistent for parenthesis to be applied equally
to all sub-elements.   So now, the workaround for SQLite
is also what the workaround for PG was previously -
when nesting compound elements, the first one usually needs
".alias().select()" called on it to wrap it inside
of a subquery.  [ticket:1665]
2010-01-25 00:35:28 +00:00
Mike Bayer 20a9cd8013 not ready to put execution_options in the text()/select() constructors yet 2010-01-24 19:18:55 +00:00
Mike Bayer fc92d14bbe - types.Binary is renamed to types.LargeBinary, it only
produces BLOB, BYTEA, or a similar "long binary" type.
New base BINARY and VARBINARY
types have been added to access these MySQL/MS-SQL specific
types in an agnostic way [ticket:1664].
2010-01-23 19:44:06 +00:00
Mike Bayer c5e29f0eed fixed the illegal_initial_chars collection + unit test, [ticket:1659] 2010-01-21 15:56:23 +00:00
Mike Bayer c3702fa516 moved the metadata step of ResultProxy into a ResultMetaData object. this also replaces PickledResultProxy.
Allows RowProxy objects to reference just the metadata they need and provides the "core" of ResultProxy
detached from the object itself, allowing ResultProxy implementations to vary more easily.  will also
enable [ticket:1635]
2010-01-20 17:48:43 +00:00
Mike Bayer 9680e6483f - added native INTERVAL type to the dialect. This supports
only the DAY TO SECOND interval type so far due to lack
  of support in cx_oracle for YEAR TO MONTH. [ticket:1467]
- The Interval type includes a "native" flag which controls
  if native INTERVAL types (postgresql + oracle) are selected
  if available, or not.  "day_precision" and "second_precision"
  arguments are also added which propagate as appropriately
  to these native types. Related to [ticket:1467].
- DefaultDialect.type_descriptor moves back to being per-dialect.
  TypeEngine/TypeDecorator key type impls to the dialect class
  + server_version_info so that the colspecs dict can be modified
  per-dialect based on server version.
- Fixed TypeDecorator's incorrect usage of _impl_dict
2010-01-18 03:00:05 +00:00
Mike Bayer 8f4871eaf2 - remove the exclusion of cx_oracle.STRING from setinputsizes by
configuring cx_oracle.UNICODE on OracleNVarChar.  Attempts
were made to pass unicode data to/from a plain VARCHAR2 with
cx_oracle, both with and without setinputsizes in use, but
it doesn't appear to be possible - therefore users will need to use
Unicode/UnicodeText with oracle if data contains non-ASCII info.
[ticket:1517]
- updated the Unicode/UnicodeText docs to reflect this, that
convert_unicode might not be enough.
- allowed convert_unicode='force' to be significant for bind parameters
as well.
2010-01-17 21:12:47 +00:00
Mike Bayer 151fa4e75c statement_options -> execution_options 2010-01-17 20:43:35 +00:00
Mike Bayer abccc06242 - added "statement_options()" to Query, to so options can be
passed to the resulting statement. Currently only
Select-statements have these options, and the only option
used is "stream_results", and the only dialect which knows
"stream_results" is psycopg2.
- Query.yield_per() will set the "stream_results" statement
option automatically.
- Added "statement_options()" to Selects, which set statement
specific options. These enable e.g. dialect specific options
such as whether to enable using server side cursors, etc.
- The psycopg2 now respects the statement option
"stream_results". This option overrides the connection setting
"server_side_cursors". If true, server side cursors will be
used for the statement. If false, they will not be used, even
if "server_side_cursors" is true on the
connection. [ticket:1619]
- added a "frozendict" from http://code.activestate.com/recipes/414283/,
adding more default collections as immutable class vars on
Query, Insert, Select
2010-01-16 22:44:04 +00:00
Mike Bayer d24133e5c5 - Fixed a column arithmetic bug that affected column
correspondence for cloned selectables which contain
free-standing column expressions.   This bug is
generally only noticeable when exercising newer
ORM behavior only availble in 0.6 via [ticket:1568],
but is more correct at the SQL expression level
as well. [ticket:1617]
2010-01-03 20:57:37 +00:00