Releases: vapor/sql-kit
SQL 2.3.2
Fixed:
SQLInsertBuilder
now sorts rows to ensure correct order.
SQL 2.3.1
SQL 2.3.0
SQL 2.2.0
SQL 2.1.0
New:
- New
SQLConnectable
protocol. All SQL builder shortcuts will now correctly appear on both database connections and pools. (#35)
pool.select().all().from(Planet.self).run()
-
SQLError
protocol. SQL implementations can now conform their errors to this protocol to provide developers with a general purpose way for detecting common SQL errors, like constraint errors. (#35). -
limit(...)
has been added toSQLSelectBuilder
. (#35) -
order(...)
has been added toSQLSelectBuilder
. (#35) -
Several new conveniences like
count(...)
,sum(...)
, etc have been added toSQLExpression
. (#35) -
New type-safe
where(...)
overloads have been added toSQLSelectBuilder
that support both arrays and single values. (#35, #33)
builder.where(\Planet.type, .in, [.smallRocky, .gasGiant])
builder.where(\Planet.type, .notEqual, .gasGiant)
SQLSelectBuilder
now supports adding a subSELECT
to the column list. (#35)
conn.select().all()
.column { select in
select.column(\Planet.id).from(Planet.self).limit(1)
}
.from(Galaxy.self)
SQL 2.0.2
Fixed:
- Added missing methods to
SQLSelectExpression
.
SQL 2.0.1
Fixed:
CREATE INDEX
no longer incorrectly serializes column names.
SQL 2.0.0
Protocols:
- The query structures this package exposes have been protocolized to allow for better support of custom SQL dialects. Instead of using concrete types like
struct
andenum
, this package now exposes protocols defining SQL capabilities. Specific SQL dialects can now create custom implementations of these protocols with additional stored properties or methods for supporting native functionality.
No serializers:
- Now that the query structures are protocolized, types can be responsible for serializing themselves. This greatly reduces the amount of code needed to serialize the SQL and keeps code organized.
New query builders:
- This package now exposes helpers for building the various SQL queries. This is a great way to build lower level queries without needing to resort to SQL strings.
let users = conn.select()
.all().from(User.self)
.where(\User.name == "Vapor")
.all(decoding: User.self)
print(users) // Future<[User]>
The above code would result in a SQL query like:
SELECT * FROM "users" WHERE "users"."name" = ?
See the updated documentation for more information:
docs.vapor.codes/3.0/sql/getting-started/
And of course, check out the API docs for detailed information about the public API:
api.vapor.codes/sql/latest/SQL/
SQL 2.0.0 Beta 3
New:
- Added
SQLCreateIndex
andSQLDropIndex
queries (#16). - New
SQLCreateIndexBuilder
for creating indexes on your database (#16).
conn.create(index: "planets_idx", on: \Planet.name).unique().run()
note: There is unfortunately no SQL standard for the
DROP INDEX
query so each SQL driver will be implementing their own drop index builder with custom syntax.