saarni [Thu, 26 May 2016 14:15:24 +0000 (10:15 -0400)]
Add TABLESAMPLE clause support.
The TABLESAMPLE clause allows randomly selecting an approximate percentage
of rows from a table. At least DB2, Microsoft SQL Server and recent
Postgresql support this standard clause.
Mike Bayer [Mon, 13 Jun 2016 19:18:13 +0000 (15:18 -0400)]
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.
Mike Bayer [Fri, 10 Jun 2016 21:24:36 +0000 (17:24 -0400)]
Ensure CTE internals are handled during clone
The CTE construct was missing a _copy_internals() method
which would handle CTE-specific structures including _cte_alias,
_restates during a clone operation.
Support `postgresql_concurrently` on index dropping.
Also adds version detection so that DROP INDEX CONCURRENTLY
only renders if the Postgresql version is 9.2 or higher;
for CREATE INDEX CONCURRENTLY, version detection is added
to allow the phrase to omit if the Postgresql version is
less than 8.2.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I597287e0ebbbe256c957a3579b58ace6848ab4f4
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/84
Mike Bayer [Sun, 8 May 2016 06:21:57 +0000 (02:21 -0400)]
Use the "committed" values when extracting many-to-one lazyload value
The scalar object set() method calls upon the lazy loader
to get at the "old" value of the attriute, however doesn't
ensure that the "committed" value of the foreign key attributes
is used. If the user has manipulated these attributes and they
themselves have pending, non committed changes, we get the
"new" value which these attributes would have set up if they
were flushed. "old" vs "new" value is always about how the
value has changed since the load, so we always have to use the
DB-persisted values for everything when looking for "old".
Add "render_nulls" flag to bulk_insert as optional performance optimization
Currently, ``Session.bulk_insert_mappings`` omits NULL values which
causes it to break up batches of inserts based on which batches
contain NULL and which do not.
By adding this flag, the same columns are rendered in the INSERT
for all rows allowing them to be batched. The downside is that
server-side defaults are omitted.
Doctext-author: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Iec5969304d4bdbf57290b200331bde02254aa3a5
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/243
Sebastian Bank [Tue, 12 Apr 2016 03:16:39 +0000 (23:16 -0400)]
Refine PG inspection methods
This refines get_schema_names(), get_table_names(),
get_view_defintion(), _get_foreign_table_names(),
and get_view_names() to use better queries and
remove unnecessary explicit encoding logic.
Mike Bayer [Fri, 3 Jun 2016 19:07:14 +0000 (15:07 -0400)]
Ensure 'options' is always present in foreign key info
Regarding 0e88bcc30ed49193b91f248123f526fa30007f22, "options"
needs to be present as a key in the dictionary because Alembic
uses this as a guide to know if the backend is even capable of
reporting on foreign key options.
Mike Bayer [Thu, 2 Jun 2016 17:52:27 +0000 (13:52 -0400)]
Skip UniqueConstraint marked by unique=True in tometadata
Fixes an issue where a Column would be copied with unique=True
and at the same time the UniqueConstraint would also be copied,
leading to duplicate UniqueConstraints in the target table,
when tometadata() is used. Imitates the same logic used
by index=True/Index to avoid duplicates. For some reason
a fix was implemented for Index long ago but never for
UniqueConstraint.
Sheila Allen [Mon, 11 Apr 2016 19:29:03 +0000 (15:29 -0400)]
Use new mxODBC 3.3.4 varbinary null symbol
Use new mxODBC 3.3.4 varbinary null symbol with VARBINARY
data types when value is None(based on similar change to pyodbc).
Fix a test to pass on mxODBC starting w 3.3.3 version
Adam Chainz [Sun, 29 May 2016 13:28:55 +0000 (14:28 +0100)]
Convert readthedocs link for their .org -> .io migration for hosted projects
As per their email ‘Changes to project subdomains’:
> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.
Test Plan: Manually visited all the links I’ve modified.
Mike Bayer [Wed, 18 May 2016 15:07:02 +0000 (11:07 -0400)]
Support "blank" schema when MetaData.schema is set
Previously, it was impossible to have a Table that has
None for a schema name when the "schema" parameter on
MetaData was set. A new symbol sqlalchemy.schema.BLANK_SCHEMA
is added which indicates that the schema name should unconditionally
be set to None. In particular, this value must be passed within
cross-schema foreign key reflection, so that a Table which
is in the "default" schema can be represented properly.
Mike Bayer [Mon, 16 May 2016 14:32:07 +0000 (10:32 -0400)]
Accommodate "callable" bound param in evaluator
Fixed bug in "evaluate" strategy of :meth:`.Query.update` and
:meth:`.Query.delete` which would fail to accommodate a bound
parameter with a "callable" value, as which occurs when filtering
by a many-to-one equality expression along a relationship.
John Vandenberg [Thu, 5 May 2016 13:26:00 +0000 (09:26 -0400)]
Fix TypeError during cx_Oracle connection
cx_Oracle connection parameters user, password and dsn must be
either a string or NULL. When they are passed a Python None object,
"TypeError: expecting string, unicode or buffer object" is raised.
Mike Bayer [Tue, 10 May 2016 16:49:56 +0000 (12:49 -0400)]
Fix label referencing in SQL Server OFFSET logic
Fixed bug where by ROW_NUMBER OVER clause applied for OFFSET
selects in SQL Server would inappropriately substitute a plain column
from the local statement that overlaps with a label name used by
the ORDER BY criteria of the statement.
Mike Bayer [Tue, 10 May 2016 15:05:30 +0000 (11:05 -0400)]
Check for duplicate calls to register_attribute_impl
Fixed bug whereby the event listeners used for backrefs could
be inadvertently applied multiple times, when using a deep class
inheritance hierarchy in conjunction with mutiple mapper configuration
steps.
Mike Bayer [Thu, 5 May 2016 21:07:40 +0000 (17:07 -0400)]
Repair _orm_columns() to accommodate text()
Fixed bug whereby passing a :func:`.text` construct to the
:meth:`.Query.group_by` method would raise an error, instead
of intepreting the object as a SQL fragment.
Mike Bayer [Wed, 27 Apr 2016 16:37:58 +0000 (11:37 -0500)]
Don't double-process ResultMetaData for BufferedColumnResultProxy
Fixed a bug in the result proxy used mainly by Oracle when binary and
other LOB types are in play, such that when query / statement caching
were used, the type-level result processors, notably that required by
the binary type itself but also any other processor, would become lost
after the first run of the statement due to it being removed from the
cached result metadata.
Mike Bayer [Wed, 27 Apr 2016 00:00:43 +0000 (19:00 -0500)]
Simplify directed graph example
Changed the "directed graph" example to no longer consider
integer identifiers of nodes as significant; the "higher" / "lower"
references now allow mutual edges in both directions.
Mike Bayer [Thu, 21 Apr 2016 14:36:19 +0000 (10:36 -0400)]
Fix result set handling for case insensitive dupe cols
Fixed bug where when using ``case_sensitive=False`` with an
:class:`.Engine`, the result set would fail to correctly accomodate
for duplicate column names in the result set, causing an error
when the statement is executed in 1.0, and preventing the
"ambiguous column" exception from functioning in 1.1.
Mike Bayer [Tue, 19 Apr 2016 20:11:23 +0000 (16:11 -0400)]
Deprecate Mapper.order_by
This is an old parameter no longer relevant to how SQLAlchemy
works, once the Query object was introduced. By deprecating it
we establish that we aren't supporting non-working use cases
and that we encourage applications to move off of the use of this
parameter.
Mike Bayer [Tue, 19 Apr 2016 19:46:37 +0000 (15:46 -0400)]
Rename Query._mapper_zero() to Query._entity_zero()
To be more descriptive of the use of _mapper_zero(), rename
it to _entity_zero(), but also supply a new _mapper_zero() function
that more strictly returns a mapper. The existing
_entity_zero() function is renamed to _query_entity_zero.
_only_mapper_zero() is removed as it isn't used. Divide up the
existing calling functions to refer to the appropriate new method.