22 Commits

Author SHA1 Message Date
Mike Bayer 8d5986fafd additional consistency for ORM/Core in tutorial
* Make sure we have blue borders for all sections
* rewrite "blue border" text, refer to textual means of determining
  subject matter for a section; "blue borders" are not a primary
  source of information
* Add some more intro text that was missing

Change-Id: I4d599e13d23bad8bb3c199a11afb53e3e9100c59
References: #9450
2023-03-08 10:10:14 -05:00
Sebastián Ramírez f81b71175d ✏️ Fix small formatting typo in "Working with Data" (#6370) 2021-04-27 22:22:01 +02:00
Mike Bayer fb9e12a689 Break up data.rst; add unions, literal_column
This breaks data.rst into three separate sub-sections,
as SELECT is getting very long.  It then adds sections
on select() + text/literal_column as well as unions
and set operations, and also tries to improve the
ORDER BY section a bit.

Change-Id: Id90e6b4ff3699b2bbcb6e2eebbd23193e2ede00a
2021-04-22 16:44:35 -04:00
Mike Bayer a58c99977e add some cross-linking for orderby/groupby docs + label examples
Change-Id: I34d4958ded8ec95e439ee47fdcb600f357cf7ae3
References: #6324
2021-04-19 11:45:09 -04:00
Mike Bayer 41de9a86c0 Return Row for CursorResult.inserted_primary_key
The tuple returned by :attr:`.CursorResult.inserted_primary_key` is now a
:class:`_result.Row` object with a named tuple interface on top of the
existing tuple interface.

Fixes: #3314
Change-Id: I85677ef60d8329648f368bf497f634758f4e087b
2021-04-11 17:15:55 -04:00
Mike Bayer 6f16636142 Clarify select_from(A).join(B.a)
Fixes: #2722
Change-Id: I025715023fa74b1f9ade4ecc8ed8712f42de727a
2021-04-11 11:10:20 -04:00
Mike Bayer 42185a1f38 document rowcount for ORM update/delete
Change-Id: I16f50cb50fc3cccc1bd7cae3a64a085b1ea68612
2021-03-31 09:42:47 -04:00
Mike Bayer 930e1a8937 refer to row elements as "elements", not columns
disambiguate between the "elements of a row" and
a "column" which is taken to mean a database column, and
remove confusing terms like "single-column ORM entity".

Change-Id: I7304bdb6dd0f60ab0c36ef3ae40b1f36b29ea291
2021-02-22 22:14:41 -05:00
Federico Caselli 227fd31d7d Fix typo on tutorial/data.rst
Change-Id: Ib7f7a92e2ae15c732659525170118288aebad9a2
2021-02-18 18:51:18 +01:00
Mike Bayer 0698992bfd fix repeated footnote
Change-Id: Ibd8239907c3cf747d0d9a0fb670e37c9913871f8
2021-02-15 11:22:13 -05:00
Mike Bayer 8fc36f3b56 Repair tests for older SQLite, timing, pypy
Change-Id: I9e425d2415d18a893342244755c7748b546fb20d
2021-02-03 16:47:53 -05:00
Mike Bayer afcab5edf6 Implement support for functions as FROM with columns clause support
Implemented support for "table valued functions" along with additional
syntaxes supported by PostgreSQL, one of the most commonly requested
features. Table valued functions are SQL functions that return lists of
values or rows, and are prevalent in PostgreSQL in the area of JSON
functions, where the "table value" is commonly referred towards as the
"record" datatype. Table valued functions are also supported by Oracle and
SQL Server.

Moved from I5b093b72533ef695293e737eb75850b9713e5e03 due
to accidental push

Fixes: #3566
Change-Id: Iea36d04c80a5ed3509dcdd9ebf0701687143fef5
2021-02-03 15:52:17 -05:00
Gord Thompson 22f65156bb Replace with_labels() and apply_labels() in ORM/Core
Replace :meth:`_orm.Query.with_labels` and
:meth:`_sql.GenerativeSelect.apply_labels` with explicit getters and
setters ``get_label_style`` and ``set_label_style`` to accommodate the
three supported label styles: ``LABEL_STYLE_DISAMBIGUATE_ONLY`` (default),
``LABEL_STYLE_TABLENAME_PLUS_COL``, and ``LABEL_STYLE_NONE``.

In addition, for Core and "future style" ORM queries,
``LABEL_STYLE_DISAMBIGUATE_ONLY`` is now the default label style. This
style differs from the existing "no labels" style in that labeling is
applied in the case of column name conflicts; with ``LABEL_STYLE_NONE``, a
duplicate column name is not accessible via name in any case.

For legacy ORM queries using :class:`_query.Query`, the table-plus-column
names labeling style applied by ``LABEL_STYLE_TABLENAME_PLUS_COL``
continues to be used so that existing test suites and logging facilities
see no change in behavior by default, however this style of labeling is no
longer required for SQLAlchemy queries to function, as result sets are
commonly matched to columns using a positional approach since SQLAlchemy
1.0.

Within test suites, all use of apply_labels()  / use_labels
now uses the new methods.    New tests added to
test/sql/test_deprecations.py nad test/orm/test_deprecations.py
to cover just the old apply_labels() method call.  Tests
in ORM that made explicit use apply_labels()/ etc. where it isn't needed
for the ORM to work correctly use default label style now.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #4757
Change-Id: I5fdcd2ed4ae8c7fe62f8be2b6d0e8f66409b6a54
2021-01-26 16:52:30 -05:00
Mike Bayer 851a3a362e Revert "Implement support for functions as FROM with columns clause support"
This reverts commit 05a31f2708.

Atom has this little button called "push" and just pushes to master,
I wasn't even *on* master.  oops
2021-01-21 11:15:06 -05:00
Mike Bayer 05a31f2708 Implement support for functions as FROM with columns clause support
WIP

Fixes: #3566
Change-Id: I5b093b72533ef695293e737eb75850b9713e5e03
2021-01-20 23:30:21 -05:00
Evan Moore 4d20df1484 Fix docs typo: subuqery -> subquery
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
Fixes #5839
(sorry, realized just now that an issue wasn't required)

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [x] A documentation / typographical error fix
	- Good to go, no issue or tests are needed
- [ ] A short code fix
	- please include the issue number, and create an issue if none exists, which
	  must include a complete example of the issue.  one line code fixes without an
	  issue and demonstration will not be accepted.
	- Please include: `Fixes: #<issue number>` in the commit message
	- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
	- please include the issue number, and create an issue if none exists, which must
	  include a complete example of how the feature would look.
	- Please include: `Fixes: #<issue number>` in the commit message
	- please include tests.

**Have a nice day!**

Closes: #5840
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5840
Pull-request-sha: b6f6af929f

Change-Id: I0b4c9b2d893e8141ee1cd21742a9b111fe371bac
2021-01-14 03:22:48 -05:00
Mike Bayer 7082e4c447 Clarify how ORM rows are returned in the tutorial
The ORM querying guide discussed how rows are returned but
the tutorial fails to introduce this important concept.

Fixes: #5706
Change-Id: I8c9585e28841b5dd86f4ab642f57cbc763635425
2020-11-17 09:58:56 -05:00
Federico Caselli f18316a14f Some small improvements on the tutorial 2.0 documents
Change-Id: I7fb37d45c29307b2213bebd0ef280d73804ac473
2020-11-13 23:03:01 +01:00
Mike Bayer 5b674ac631 Allow multiple returning() calls
Multiple calls to "returning", e.g. :meth:`_sql.Insert.returning`,
may now be chained to add new columns to the RETURNING clause.

Fixes: #5695
Change-Id: Ie2dac4162f686c730e000e31dccfb38f9ce9c96e
2020-11-11 11:57:59 -05:00
Mike Bayer 1f7969ae50 Warn / raise for returning() / return_defaults() combinations
A warning is emmitted if a returning() method such as
:meth:`_sql.Insert.returning` is called multiple times, as this does not
yet support additive operation.  Version 1.4 will support additive
operation for this.  Additionally, any combination of the
:meth:`_sql.Insert.returning` and :meth:`_sql.Insert.return_defaults`
methods now raises an error as these methods are mutually exclusive;
previously the operation would fail silently.

Fixes: #5691
Change-Id: Id95e0f9da48bba0b59439cb26564f0daa684c8e3
2020-11-11 11:36:06 -05:00
Mike Bayer afb26d79d7 Remove misleading correlation examples
add links to tutorial docs

Fixes: #5694
Change-Id: I10a8e3f46a115945ded36d4ee59165c056c10f7a
2020-11-11 10:42:09 -05:00
Mike Bayer 654b462d66 tutorial 2.0 WIP
Add SelectBase.exists() method as it seems strange this is
not available already.  The Exists construct itself does
not provide full SELECT-building capabilities so it makes
sense this should be used more like a scalar_subquery.

Make sure stream_results is getting set up when yield_per
is used, for 2.0 style statements as well.  this was
hardcoded inside of Query.yield_per() and is now moved
to take place within QueryContext.

Change-Id: Icafcd4fd9b708772343d56edf40995c9e8f835d6
2020-10-31 13:44:53 -04:00