Skip to content

Releases: vapor/sql-kit

Add support for RETURNING clause

24 Jun 20:25
8b82edd
Compare
Choose a tag to compare
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 of SQLReturning 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

22 Jun 20:23
d044d36
Compare
Choose a tag to compare
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's SQLDialect
  • Boolean literal interpolation, e.g. \(literal: true), for rendering correctly escaped boolean literals according to the database's SQLDialect
  • String literal interpolation, e.g. \(literal: "hello"), for rendering strings as correctly escaped literal values in the database's SQLDialect
  • 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's SQLDialect - 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 for INSERT, for example.
  • A + operator for concatenating two SQLQueryStrings. Credit for this functionality goes to @t-ae in #111.
  • Array<SQLQueryString>.joined(separator:), similar to Array<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

20 Jun 04:08
ced1bbf
Compare
Choose a tag to compare
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`

18 Jun 19:47
de35216
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.
  • SQLDropIndex now supports IF EXISTS if the underlying database dialect does.

  • SQLDropIndex now supports SQLDropBehavior (CASCADE and RESTRICT) if the underlying database dialect does.

  • Added SQLDropIndexBuilder for convenient creation and execution of SQLDropIndex queries.

  • Fix minor grammar typos in some comments.

ALTER TABLE constraints

18 May 18:18
3800a6f
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Adds support for adding and dropping constraints in ALTER TABLE queries.

SQLKit 3.0.0

24 Apr 14:48
1e02396
Compare
Choose a tag to compare

Adds a `normalizeSQLConstraint` method

13 Apr 23:33
f777df2
Compare
Choose a tag to compare
Pre-release
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

04 Mar 23:06
64c2af0
Compare
Choose a tag to compare
Pre-release
This patch was authored and released by @tanner0101.

Adds a SQLDialect option for overriding SQLDataType's serialization.

Fix SQLRaw initializer

04 Mar 18:25
0d48713
Compare
Choose a tag to compare
Pre-release

binds is now correctly set when using SQLRaw's initializer (#99, fixes #95).

This patch was authored and released by @tanner0101.

Release Candidate 1

28 Feb 20:45
948eae1
Compare
Choose a tag to compare
Release Candidate 1 Pre-release
Pre-release

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.