Skip to content

Releases: vapor/sql-kit

SQL 2.2.0

31 Oct 21:18
839cf96
Compare
Choose a tag to compare

New:

  • Adds a convenience method for using COALESCE. (#42, #43)
conn.select().column(.coalesce(.sum(\Planet.id), 0), as: "id_sum")...
SELECT COALESCE(SUM(`id`), 0) as `id_sum` ...

SQL 2.1.0

20 Sep 15:17
a35cf1d
Compare
Choose a tag to compare

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 to SQLSelectBuilder. (#35)

  • order(...) has been added to SQLSelectBuilder. (#35)

  • Several new conveniences like count(...), sum(...), etc have been added to SQLExpression. (#35)

  • New type-safe where(...)overloads have been added to SQLSelectBuilder 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 sub SELECT 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

17 Jul 02:19
Compare
Choose a tag to compare

Fixed:

  • Added missing methods to SQLSelectExpression.

SQL 2.0.1

16 Jul 23:25
Compare
Choose a tag to compare

Fixed:

  • CREATE INDEX no longer incorrectly serializes column names.

SQL 2.0.0

16 Jul 23:14
3713b41
Compare
Choose a tag to compare

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 and enum, 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

22 Jun 21:50
f89155d
Compare
Choose a tag to compare
SQL 2.0.0 Beta 3 Pre-release
Pre-release

New:

  • Added SQLCreateIndex and SQLDropIndex 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.

SQL 2.0.0 Beta 2

21 Jun 22:46
5127aaf
Compare
Choose a tag to compare
SQL 2.0.0 Beta 2 Pre-release
Pre-release

Fixed:

  • Replaced SQLConflictResolution with SQLForeignKeyAction (#15).
  • == and != now check for nil (#13).

SQL 2.0.0 Beta 1.0.1

21 Jun 22:47
Compare
Choose a tag to compare
SQL 2.0.0 Beta 1.0.1 Pre-release
Pre-release
2.0.0-beta.1.0.1

conform GenericSQLColumnIdentifier to hashable

SQL 2.0.0 Beta 1

19 Jun 22:41
0a0d247
Compare
Choose a tag to compare
SQL 2.0.0 Beta 1 Pre-release
Pre-release

New:

  • SQL data structs have been refactored to protocols. This allows for the various SQL flavors to implement custom data types capable of defining their own storage and serialization.

SQL 1.0.0

23 Apr 20:23
1bb9427
Compare
Choose a tag to compare

Introducing SQL 1.0! 🎉
*️⃣ Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL.

Docs:
https://docs.vapor.codes/3.0/sql/getting-started/

API Docs:
https://api.vapor.codes/sql/latest/SQL

⚠️ This package is brand new and may still be subject to change as we work out the APIs. Keep an eye on the release notes.


This package has been moved here from the vapor/database-kit repo.

Milestone:
1.0.0