Skip to content

Conversation

@gwynne
Copy link
Member

@gwynne gwynne commented Mar 29, 2025

These changes are now available in 1.51.0

Adds .sql(unsafeRaw:), .sql(embed:), and .sql(_:) helpers for the following types to FluentSQL:

  • DatabaseQuery.Action
  • DatabaseQuery.Aggregate
  • DatabaseQuery.Aggregate.Method
  • DatabaseQuery.Filter.Method
  • DatabaseQuery.Filter.Relation
  • DatabaseQuery.Join.Method
  • DatabaseQuery.Sort.Direction

Additional changes:

  • Schema.spaceIfNotAliased is now public (it was previously internal).
  • Updated the minimum version requirements for a couple of dependencies and made the FluentKit target's product dependencies more explicit.
  • DatabaseQuery.Limit.custom(_:) and DatabaseQuery.Offset.custom(_:) are now deprecated, reflecting the fact that any use of them causes an unconditional fatalError(). Due to design limitations in SQLKit, it is not possible to implement them correctly instead of erroring.
  • As promised, the use of @_spi has been removed in favor of the package access modifier now that we require Swift 5.9. This removes public symbols from the API, but because those symbols were SPI and had been explicitly documented as becoming non-public as of 5.9, this does not constitute a semver-major break. Anyone who was using the SPIs did so at their own risk.
  • Fixed a missed #if condition for one of the bits of Mirror bypass logic (it still said <6 instead of <6.1).
  • A focused code formatting pass was made to remove lots of redundant uses of the return keyword, pretty much for the sole reason that I felt like doing it. Fixed a few incorrect comments and code style quirks along the way too, but only a few.

gwynne added 5 commits March 29, 2025 02:23
…promise to stop using @_spi(). Because these previously public methods were SPI and explicitly documented as not being public in the near future, this is not a semver-major break.
…tom(_:), as using them always causes a fatalError()
… DatabaseQuery.Aggregate.Method, DatabaseQuery.Filter.Method, DatabaseQuery.Filter.Relation, DatabaseQuery.Join.Method, and DatabaseQuery.Sort.Direction.
@gwynne gwynne added enhancement New feature or request semver-minor Contains new APIs labels Mar 29, 2025
@gwynne gwynne requested review from 0xTim, MahdiBM and ptoffy March 29, 2025 07:41
@codecov
Copy link

codecov bot commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 30.62500% with 222 lines in your changes missing coverage. Please review.

Project coverage is 24.24%. Comparing base (a2f2181) to head (16a80a6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/FluentSQL/DatabaseQuery+SQL.swift 0.00% 44 Missing ⚠️
Sources/FluentSQL/SQLSchemaConverter.swift 39.02% 25 Missing ⚠️
...luentKit/Query/Database/DatabaseQuery+Filter.swift 19.23% 21 Missing ⚠️
...s/FluentKit/Properties/BooleanPropertyFormat.swift 0.00% 18 Missing ⚠️
Sources/FluentSQL/SQLQueryConverter.swift 57.89% 16 Missing ⚠️
...FluentKit/Query/Database/DatabaseQuery+Value.swift 7.14% 13 Missing ⚠️
.../FluentKit/Query/Database/DatabaseQuery+Join.swift 0.00% 11 Missing ⚠️
Sources/FluentKit/FluentError.swift 0.00% 10 Missing ⚠️
...ntKit/Query/Database/DatabaseQuery+Aggregate.swift 0.00% 8 Missing ⚠️
Sources/FluentKit/Properties/Relation.swift 12.50% 7 Missing ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #633      +/-   ##
==========================================
- Coverage   24.26%   24.24%   -0.03%     
==========================================
  Files         149      149              
  Lines        9348     9397      +49     
==========================================
+ Hits         2268     2278      +10     
- Misses       7080     7119      +39     
Files with missing lines Coverage Δ
Sources/FluentKit/Enum/EnumProperty.swift 81.63% <100.00%> (ø)
Sources/FluentKit/Enum/OptionalEnumProperty.swift 81.66% <100.00%> (ø)
Sources/FluentKit/Model/Fields.swift 97.43% <100.00%> (ø)
Sources/FluentKit/Model/Schema.swift 100.00% <100.00%> (ø)
Sources/FluentKit/Properties/FieldKey.swift 100.00% <100.00%> (ø)
...uentKit/Query/Builder/QueryBuilder+Aggregate.swift 56.96% <100.00%> (+1.26%) ⬆️
...luentKit/Query/Builder/QueryBuilder+Paginate.swift 75.00% <100.00%> (ø)
...es/FluentKit/Query/Builder/QueryBuilder+Sort.swift 100.00% <100.00%> (+15.00%) ⬆️
Sources/FluentKit/Query/Builder/QueryBuilder.swift 73.51% <100.00%> (ø)
Sources/FluentKit/Schema/DatabaseSchema.swift 54.54% <ø> (ø)
... and 28 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


static var spaceIfNotAliased: String? {
return self.alias == nil ? self.space : nil
public static var spaceIfNotAliased: String? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Copy link
Member Author

@gwynne gwynne Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It certainly is. But I completely forgot to mention it in the commit log or the PR description 😅

@gwynne gwynne merged commit 788f4b9 into main Mar 29, 2025
16 checks passed
@gwynne gwynne deleted the add-missing-fluentsql-extensions branch March 29, 2025 17:33
bwdmr pushed a commit to bwdmr/fluent-kit that referenced this pull request Dec 17, 2025
…luentSQL (vapor#633)

* Update dependency version requirements

* A minor code formatting pass getting rid of excess `return`s and fixing some comments.

* The package access modifier was introduced in Swift 5.9. Fulfill the promise to stop using @_spi(). Because these previously public methods were SPI and explicitly documented as not being public in the near future, this is not a semver-major break.

* Deprecate DatabaseQuery.Limit.custom(_:) and DatabaseQuery.Offset.custom(_:), as using them always causes a fatalError()

* Add .sql() helpers for DatabaseQuery.Action, DatabaseQuery.Aggregate, DatabaseQuery.Aggregate.Method, DatabaseQuery.Filter.Method, DatabaseQuery.Filter.Relation, DatabaseQuery.Join.Method, and DatabaseQuery.Sort.Direction.

* Workaround for silly Swift 5.9 bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request semver-minor Contains new APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants