Releases: vapor/sql-kit
Add support for RETURNING clause
This patch was authored by @grahamburgsma and released by @tanner0101.
Adds support for SQL RETURNING
clauses on supported databases (#110).
- Adds new
SQLReturning
expression to support returning columns on insert / update / delete queries.
var select = SQLSelect(...)
select.returning = ...
- Adds
SQLReturningBuilder
for use ofSQLReturning
in query builders.
db.delete()
.from("planets")
.returning("*")
.all()
The returning
method supports multiple columns or identifiers.
builder.returning("id", "name")
It also supports qualified names using SQLColumn
.
builder.returning(SQLColumn("name", table: "planets"))
- Adds new
SQLDialect
option for checking if the current database supports returning.
if database.dialect.supportsReturning {
builder.returning("*")
} else {
// Fallback.
}
Add additional interpolations, constructors, and operations to SQLQueryString
This patch was authored and released by @gwynne.
Several new capabilities are available on SQLQueryString
, as used by SQLRawBuilder
:
- Integer literal interpolation, e.g.
\(literal: 1)
, for rendering correctly escaped numeric literals according to the database'sSQLDialect
- Boolean literal interpolation, e.g.
\(literal: true)
, for rendering correctly escaped boolean literals according to the database'sSQLDialect
- String literal interpolation, e.g.
\(literal: "hello")
, for rendering strings as correctly escaped literal values in the database'sSQLDialect
- Arrays of string literals interpolation, e.g.
\(literals: ["hello", "world", "how", "are", "you"], joinedBy: " ")
- SQL identifier interpolation, e.g.
\(ident: "created_at")
, for rendering names as correctly escaped identifiers according to the database'sSQLDialect
- identifiers are usually table names, column names, alias names for tables and columns, and other similar items. PostgreSQL and SQLite enclose identifiers in"
characters; MySQL uses backticks. - Arrays of SQL identifiers interpolation, e.g.
\(idents: ["id", "created_at", "updated_at"], joinedBy: ", ")
- great for generating column name lists forINSERT
, for example. - A
+
operator for concatenating twoSQLQueryString
s. Credit for this functionality goes to @t-ae in #111. Array<SQLQueryString>.joined(separator:)
, similar toArray<String>.joined(separator:)
. Credit for this functionality goes to @t-ae in #111.- Improved tests for
SQLQueryString
. Partial credit for the improvements goes to @t-ae in #111.
Allow binding a list of values in SQLQueryString
This patch was authored by @grahamburgsma and released by @gwynne.
This addition allows binding a list of values. This is useful for IN
statements for example WHERE column_name IN (value1, value2, ...)
.
Usage
let ids = [1, 2, 3...]
raw("...WHERE IN (\(binds: ids))")
Improve `SQLDropIndex`, add `SQLDropIndexBuilder`
This patch was authored and released by @gwynne.
-
SQLDropIndex
now supportsIF EXISTS
if the underlying database dialect does. -
SQLDropIndex
now supportsSQLDropBehavior
(CASCADE
andRESTRICT
) if the underlying database dialect does. -
Added
SQLDropIndexBuilder
for convenient creation and execution ofSQLDropIndex
queries. -
Fix minor grammar typos in some comments.
ALTER TABLE constraints
This patch was authored and released by @tanner0101.
Adds support for adding and dropping constraints in ALTER TABLE queries.
SQLKit 3.0.0
Docs:
https://github.com/vapor/sql-kit/blob/master/README.md
More information on Vapor 4 official release:
https://forums.swift.org/t/vapor-4-official-release-begins/34802
Adds a `normalizeSQLConstraint` method
This patch was authored and released by @mcdappdev.
Adds a normalizeSQLConstraint
method to SQLDialect
so that the drivers can truncate constraint identifiers that are too long.
Custom SQLDataType dialect support
This patch was authored and released by @tanner0101.
Adds a SQLDialect option for overriding SQLDataType's serialization.
Fix SQLRaw initializer
binds
is now correctly set when using SQLRaw
's initializer (#99, fixes #95).
This patch was authored and released by @tanner0101.
Release Candidate 1
Updates to Swift 5.2 and macOS 10.15. Adds more CI testing.
Release candidates represent the final shift toward focusing on bug fixes and documentation. Breaking changes will only be accepted for critical issues. We expect a final release of this package shortly after Swift 5.2's release date.