Full Code of MihaelIsaev/SwifQL for AI

master 465f7a5766ac cached
202 files
443.7 KB
123.1k tokens
1 requests
Download .txt
Showing preview only (496K chars total). Download the full file or copy to clipboard to get everything.
Repository: MihaelIsaev/SwifQL
Branch: master
Commit: 465f7a5766ac
Files: 202
Total size: 443.7 KB

Directory structure:
gitextract_0k67_6b0/

├── .github/
│   └── workflows/
│       └── test.yml
├── .gitignore
├── LICENSE
├── Package.swift
├── README.md
├── Sources/
│   └── SwifQL/
│       ├── Alias.swift
│       ├── Builders/
│       │   ├── CaseWhen.swift
│       │   ├── Distinct.swift
│       │   ├── GenericTableSelector.swift
│       │   ├── NewColumn.swift
│       │   ├── PostgresArray.swift
│       │   ├── PostgresJsonObject.swift
│       │   ├── QueryBuilder.swift
│       │   ├── Schema/
│       │   │   ├── CreateSchemaBuilder.swift
│       │   │   ├── DropSchemaBuilder.swift
│       │   │   ├── UpdateSchemaChangeOwner.swift
│       │   │   └── UpdateSchemaRename.swift
│       │   ├── SwifQLJoinBuilder.swift
│       │   ├── SwifQLSelectBuilder.swift
│       │   ├── Table/
│       │   │   ├── CreateTableBuilder.swift
│       │   │   ├── DropTableBuilder.swift
│       │   │   └── UpdateTableBuilder.swift
│       │   ├── Union.swift
│       │   └── With.swift
│       ├── Codable.swift
│       ├── Column.swift
│       ├── Constraint.swift
│       ├── Dialect/
│       │   ├── Dialect+MySQL.swift
│       │   ├── Dialect+Postgres.swift
│       │   └── Dialect.swift
│       ├── Enum.swift
│       ├── Extensions/
│       │   ├── Array+SwifQLable.swift
│       │   ├── Column+AutoType.swift
│       │   ├── Decodable+Table.swift
│       │   └── StringExtensions.swift
│       ├── ExtractFieldValue.swift
│       ├── FluentKitFieldable.swift
│       ├── FormattedKeyPath.swift
│       ├── Formatter.swift
│       ├── Functions/
│       │   ├── Functions+Array.swift
│       │   ├── Functions+General.swift
│       │   ├── Functions+MySQL.swift
│       │   ├── Functions+Numeric.swift
│       │   ├── Functions+PostgresBool.swift
│       │   ├── Functions+PostgresJSON.swift
│       │   ├── Functions+PostgresJSONB.swift
│       │   ├── Functions+PostgresSeries.swift
│       │   ├── Functions+PostgresTime.swift
│       │   ├── Functions+String.swift
│       │   ├── Functions+TextSearch.swift
│       │   ├── Functions+Window.swift
│       │   └── Functions.swift
│       ├── HybridOperator.swift
│       ├── IndexItem.swift
│       ├── IndexType.swift
│       ├── KeyPath.swift
│       ├── Keypathable.swift
│       ├── Operators.swift
│       ├── Parts/
│       │   ├── AliasPart.swift
│       │   ├── ArrayPart.swift
│       │   ├── BoolPart.swift
│       │   ├── ColumnPart.swift
│       │   ├── DatePart.swift
│       │   ├── HybridOperatorPart.swift
│       │   ├── KeyPathPart.swift
│       │   ├── NullPart.swift
│       │   ├── OperatorPart.swift
│       │   ├── SafeValuePart.swift
│       │   ├── TablePart.swift
│       │   ├── TableWithAliasPart.swift
│       │   └── UnsafeValuePart.swift
│       ├── Path/
│       │   ├── Path+Column.swift
│       │   ├── Path+Schema.swift
│       │   ├── Path+SchemaWithTable.swift
│       │   ├── Path+SchemaWithTableAndColumn.swift
│       │   ├── Path+Table.swift
│       │   ├── Path+TableWithColumn.swift
│       │   └── Path.swift
│       ├── Predicates.swift
│       ├── Prepared.swift
│       ├── QueryBuilderable.swift
│       ├── QueryParts.swift
│       ├── ReferentialAction.swift
│       ├── ResultBuilders/
│       │   └── SwifQLableResultBuilder.swift
│       ├── Schema.swift
│       ├── Schemable.swift
│       ├── SplittedQuery.swift
│       ├── SwifQL.swift
│       ├── SwifQLable+Parts/
│       │   ├── SwifQLable+Action.swift
│       │   ├── SwifQLable+Add.swift
│       │   ├── SwifQLable+AddQuery.swift
│       │   ├── SwifQLable+After.swift
│       │   ├── SwifQLable+All.swift
│       │   ├── SwifQLable+Alter.swift
│       │   ├── SwifQLable+And.swift
│       │   ├── SwifQLable+Any.swift
│       │   ├── SwifQLable+As.swift
│       │   ├── SwifQLable+Asterisk.swift
│       │   ├── SwifQLable+Before.swift
│       │   ├── SwifQLable+Begin.swift
│       │   ├── SwifQLable+Between.swift
│       │   ├── SwifQLable+Cascade.swift
│       │   ├── SwifQLable+Check.swift
│       │   ├── SwifQLable+Column.swift
│       │   ├── SwifQLable+Commit.swift
│       │   ├── SwifQLable+Conflict.swift
│       │   ├── SwifQLable+Constraint.swift
│       │   ├── SwifQLable+Create.swift
│       │   ├── SwifQLable+Default.swift
│       │   ├── SwifQLable+Delete.swift
│       │   ├── SwifQLable+Distinct.swift
│       │   ├── SwifQLable+Do.swift
│       │   ├── SwifQLable+Drop.swift
│       │   ├── SwifQLable+End.swift
│       │   ├── SwifQLable+Epoch.swift
│       │   ├── SwifQLable+Exists.swift
│       │   ├── SwifQLable+Filter.swift
│       │   ├── SwifQLable+From.swift
│       │   ├── SwifQLable+Fulltext.swift
│       │   ├── SwifQLable+Function.swift
│       │   ├── SwifQLable+GroupBy.swift
│       │   ├── SwifQLable+Having.swift
│       │   ├── SwifQLable+ILike.swift
│       │   ├── SwifQLable+If.swift
│       │   ├── SwifQLable+In.swift
│       │   ├── SwifQLable+InsertInto.swift
│       │   ├── SwifQLable+Interval.swift
│       │   ├── SwifQLable+IsNotNull.swift
│       │   ├── SwifQLable+IsNull.swift
│       │   ├── SwifQLable+Items.swift
│       │   ├── SwifQLable+Join.swift
│       │   ├── SwifQLable+Key.swift
│       │   ├── SwifQLable+Like.swift
│       │   ├── SwifQLable+Limit.swift
│       │   ├── SwifQLable+No.swift
│       │   ├── SwifQLable+Not.swift
│       │   ├── SwifQLable+NotBetween.swift
│       │   ├── SwifQLable+NotExists.swift
│       │   ├── SwifQLable+NotILike.swift
│       │   ├── SwifQLable+NotIn.swift
│       │   ├── SwifQLable+NotLike.swift
│       │   ├── SwifQLable+Nothing.swift
│       │   ├── SwifQLable+Null.swift
│       │   ├── SwifQLable+Offset.swift
│       │   ├── SwifQLable+On.swift
│       │   ├── SwifQLable+Or.swift
│       │   ├── SwifQLable+OrderBy.swift
│       │   ├── SwifQLable+Over.swift
│       │   ├── SwifQLable+Overlaps.swift
│       │   ├── SwifQLable+Owner.swift
│       │   ├── SwifQLable+PartitionBy.swift
│       │   ├── SwifQLable+Primary.swift
│       │   ├── SwifQLable+Raw.swift
│       │   ├── SwifQLable+References.swift
│       │   ├── SwifQLable+Rename.swift
│       │   ├── SwifQLable+Restrict.swift
│       │   ├── SwifQLable+Return.swift
│       │   ├── SwifQLable+Returning.swift
│       │   ├── SwifQLable+Rollback.swift
│       │   ├── SwifQLable+Schema.swift
│       │   ├── SwifQLable+Select.swift
│       │   ├── SwifQLable+Semicolon.swift
│       │   ├── SwifQLable+Set.swift
│       │   ├── SwifQLable+Space.swift
│       │   ├── SwifQLable+Subscript.swift
│       │   ├── SwifQLable+Table.swift
│       │   ├── SwifQLable+Timestamp.swift
│       │   ├── SwifQLable+To.swift
│       │   ├── SwifQLable+Type.swift
│       │   ├── SwifQLable+Union.swift
│       │   ├── SwifQLable+Unique.swift
│       │   ├── SwifQLable+Update.swift
│       │   ├── SwifQLable+Value.swift
│       │   ├── SwifQLable+Values.swift
│       │   ├── SwifQLable+Where.swift
│       │   ├── SwifQLable+WhereExists.swift
│       │   ├── SwifQLable+WhereNotExists.swift
│       │   ├── SwifQLable+Window.swift
│       │   └── SwifQLable+With.swift
│       ├── SwifQLable.swift
│       ├── SwifQLableArraySeparator.swift
│       ├── Table.swift
│       ├── TableAlias.swift
│       ├── Type+Autodetect.swift
│       ├── Type+SwifQLable.swift
│       ├── Type.swift
│       └── _Todo.swift
└── Tests/
    └── SwifQLTests/
        ├── BuilderTests.swift
        ├── CaseTests.swift
        ├── DirectiveTests.swift
        ├── ExistsTests.swift
        ├── FnTests.swift
        ├── FromTests.swift
        ├── JsonTests.swift
        ├── OrderTests.swift
        ├── OtherTests.swift
        ├── PredicateTest.swift
        ├── SelectTests.swift
        ├── SubqueryTests.swift
        ├── SwifQLTestCase.swift
        ├── TableEncoding.swift
        └── WithTests.swift

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/test.yml
================================================
name: test
on: [push, pull_request]
jobs:
  swift_6_0:
    container: swift:6.0
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - run: swift test


================================================
FILE: .gitignore
================================================
Packages
.build
.DS_Store
*.xcodeproj
DerivedData/
Package.resolved
.swiftpm


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2018 Mihael Isaev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: Package.swift
================================================
// swift-tools-version:6.0

import PackageDescription

let package = Package(
    name: "SwifQL",
    platforms: [
       .macOS(.v10_15)
    ],
    products: [
        // 💎 Swift lib that gives an ability to build complex raw SQL-queries in strong-type declarative way
        .library(name: "SwifQL", targets: ["SwifQL"]),
    ],
    dependencies: [],
    targets: [
        .target(name: "SwifQL", dependencies: []),
        .testTarget(name: "SwifQLTests", dependencies: [.target(name: "SwifQL")]),
    ],
    swiftLanguageModes: [.v5]
)


================================================
FILE: README.md
================================================
[![Mihael Isaev](https://user-images.githubusercontent.com/1272610/53677263-7ecbfe00-3cc6-11e9-9049-2d2b9a2d7947.png)](http://mihaelisaev.com)

<p align="center">
    <a href="LICENSE">
        <img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
    </a>
    <a href="https://swift.org">
        <img src="https://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
    </a>
    <img src="https://img.shields.io/github/workflow/status/MihaelIsaev/SwifQL/test" alt="Github Actions">
    <a href="https://discord.gg/q5wCPYv">
        <img src="https://img.shields.io/discord/612561840765141005" alt="Swift.Stream">
    </a>
</p>
<p align="center">
    <a href="https://swiftpackageindex.com/SwifQL/SwifQL">
        <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FSwifQL%2FSwifQL%2Fbadge%3Ftype%3Dswift-versions">
    </a>
    <a href="https://swiftpackageindex.com/SwifQL/SwifQL">
        <img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FSwifQL%2FSwifQL%2Fbadge%3Ftype%3Dplatforms">
    </a>
</p>
<br>

This lib can be used either stand alone, or with frameworks like Vapor, Kitura, Perfect and others

We recommend to use it with our [Bridges](https://github.com/SwifQL/Bridges) lib which is built on top of SwifQL and support all its flexibility

It supports PostgreSQL and MySQL. And it's not so hard to add other dialects 🙂 just check [SwifQL/Dialect](https://github.com/SwifQL/SwifQL/tree/master/Sources/SwifQL/Dialect) folder

Please feel free to ask any questions in issues, and also you could find me in the [Discord app](https://discordapp.com) as `@iMike#3049` or even better just join **#swifql** channel on [Vapor's Discord server](https://discord.gg/vapor) 🙂

> NOTE:
>
> If you haven't found some functions available out-of-the-box
> then please check files like `SwifQLable+Select` and others in `Sources/SwifQL` folder
> to ensure how easy it is to extend SwifQL to support anything you need 🚀
>
> And feel free to send pull requests with your awesome new extensions ❤️

### Support SwifQL development by giving a ⭐️

## Installation
### With Vapor 4 + [Bridges](https://github.com/SwifQL/Bridges) + PostgreSQL
```swift
.package(url: "https://github.com/vapor/vapor.git", from:"4.0.0-rc"),
.package(url: "https://github.com/SwifQL/VaporBridges.git", from:"1.0.0-rc"),
.package(url: "https://github.com/SwifQL/PostgresBridge.git", from:"1.0.0-rc"),
.target(name: "App", dependencies: [
    .product(name: "Vapor", package: "vapor"),
    .product(name: "VaporBridges", package: "VaporBridges"),
    .product(name: "PostgresBridge", package: "PostgresBridge")
]),
```

### With Vapor 4 + [Bridges](https://github.com/SwifQL/Bridges) + MySQL
```swift
.package(url: "https://github.com/vapor/vapor.git", from:"4.0.0-rc"),
.package(url: "https://github.com/SwifQL/VaporBridges.git", from:"1.0.0-rc"),
.package(url: "https://github.com/SwifQL/MySQLBridge.git", from:"1.0.0-rc"),
.target(name: "App", dependencies: [
    .product(name: "Vapor", package: "vapor"),
    .product(name: "VaporBridges", package: "VaporBridges"),
    .product(name: "MySQLBridge", package: "MySQLBridge")
]),
```

### Pure
```swift
.package(url: "https://github.com/MihaelIsaev/SwifQL.git", from:"2.0.0-beta"),
.target(name: "App", dependencies: [
    .product(name: "SwifQL", package: "SwifQL"),
]),
```

### Pure on NIO2
```swift
.package(url: "https://github.com/MihaelIsaev/SwifQL.git", from:"2.0.0-beta"),
.package(url: "https://github.com/MihaelIsaev/SwifQLNIO.git", from:"2.0.0"),
.target(name: "App", dependencies: [
    .product(name: "SwifQL", package: "SwifQL"),
    .product(name: "SwifQLNIO", package: "SwifQLNIO"),
]),
```

#### Pure on NIO1 (deprecated)
```swift
.package(url: "https://github.com/MihaelIsaev/SwifQL.git", from:"1.0.0"),
.package(url: "https://github.com/MihaelIsaev/SwifQLNIO.git", from:"1.0.0"),
.target(name: "App", dependencies: ["SwifQL", "SwifQLNIO"]),
```

#### With Vapor 3 + Fluent (deprecated)
```swift
.package(url: "https://github.com/MihaelIsaev/SwifQL.git", from:"1.0.0"),
.package(url: "https://github.com/MihaelIsaev/SwifQLVapor.git", from:"1.0.0"),
.target(name: "App", dependencies: ["Vapor", "SwifQL", "SwifQLVapor"]),
```

## Philosophy

This lib gives an ability to build absolutely any SQL query from simplest to monster complex.

Example of simple query
```sql
SELECT * FROM "User" WHERE "email" = 'john.smith@gmail.com'
```
build it with pure SwifQL this way
```swift
SwifQL.select(User.table.*).from(User.table).where(\User.email == "john.smith@gmail.com")
```
or with SwifQL + [Bridges](https://github.com/SwifQL/Bridges)
```swift
SwifQL.select(User.table.*).from(User.table).where(\User.$email == "john.smith@gmail.com")
// or shorter
User.select.where(\User.$email == "john.smith@gmail.com")
```

## Usage

### Preparation

> 💡 TIP: It is simpler and more powerful with [Bridges](https://github.com/SwifQL/Bridges)

Of course you have to import the lib
```swift
import SwifQL
```

#### For v1 Your table models should be conformed to `Tableable` protocol
```swift
extension MyTable: Tableable {}
```

#### For v2 Your table models should be conformed to `Table` protocol
```swift
extension MyTable: Table {}
```

### How to build query

> Instead of writing `Model.self` you should write `Model.table`, cause without Vapor you should conform your models to `Table`, and with Vapor its `Model`s are already conforms to `Table`.

```swift
let query = SwifQL.select(\User.email, \User.name, \User.role)
                  .from(User.table)
                  .orderBy(.asc(\User.name))
                  .limit(10)
```
or with SwifQL + [Bridges](https://github.com/SwifQL/Bridges)
```swift
let query = SwifQL.select(\User.$email, \User.$name, \User.$role)
                  .from(User.table)
                  .orderBy(.asc(\User.$name))
                  .limit(10)
// or shorter
User.select(\.$email, \.$name, \.$role).orderBy(.asc(\User.$name)).limit(10)
```

### How to print raw query

There are two options

##### 1. Get just plain query
```swift
let rawSQLString = query.prepare(.psql).plain
```

or when using SwifQLSelectBuilder() - see below

```swift
let rawSQLBuilderString = query.build().prepare(.psql).plain
```

##### 2. Get object splitted into: formatted raw SQL string with $ symbols, and separated array with values
```swift
let splittedQuery = query.prepare(.psql).splitted
let formattedSQLQuery = splittedQuery.query // formatted raw SQL string with $ symbols instead of values
let values = splittedQuery.values // an array of [Encodable] values
```

Then just put it into your database driver somehow 🙂 or use [Bridges](https://github.com/SwifQL/Bridges)

### How to execute query?

SwifQL is only about building queries. For execution you have to use your favourite database driver.

Below you can see an example for SwifQL + Vapor4 + [Bridges](https://github.com/SwifQL/Bridges) + PostgreSQL

> 💡 You can get connection on both `Application` and `Request` objects.

Example for `Application` object e.g. for `configure.swift` file
```swift
// Called before your application initializes.
public func configure(_ app: Application) throws {
    app.postgres.connection(to: .myDb1) { conn in
        SwifQL.select(User.table.*).from(User.table).execute(on: conn).all(decoding: User.self).flatMap { rows in
            print("yaaay it works and returned \(rows.count) rows!")
        }
    }.whenComplete {
        switch $0 {
        case .success: print("query was successful")
        case .failure(let error): print("query failed: \(error)")
        }
    }
}
```
Example for `Request` object
```swift
func routes(_ app: Application) throws {
    app.get("users") { req -> EventLoopFuture<[User]> in
        req.postgres.connection(to: .myDb1) { conn in
            SwifQL.select(User.table.*).from(User.table).execute(on: conn).all(decoding: User.self)
        }
    }
}
```

> 💡 In examples above we use `.all(decoding: User.self)` for decoding results, but we also can use `.first(decoding: User.self).unwrap(or: Abort(.notFound))` to get only first row and unwrap it since it may be nil.

## Insert Into

### Single record
SQL example
```sql
INSERT INTO "User" ("email", "name") VALUES ('john@gmail.com', 'John Doe'), ('sam@gmail.com', 'Samuel Jackson')
```
SwifQL representation
```swift
SwifQL.insertInto(User.table, fields: \User.email, \User.name).values("john@gmail.com", "John Doe")
```
or with SwifQL + [Bridges](https://github.com/SwifQL/Bridges)
```swift
User(email: "john@gmail.com", name: "John Doe").insert(on: conn)
```

### Batch
SQL example
```sql
INSERT INTO "User" ("email", "name") VALUES ('john@gmail.com', 'John Doe'), ('sam@gmail.com', 'Samuel Jackson')
```
SwifQL representation
```swift
SwifQL.insertInto(User.table, fields: \User.email, \User.name).values(array: ["john@gmail.com", "John Doe"], ["sam@gmail.com", "Samuel Jackson"])
```
or with SwifQL + [Bridges](https://github.com/SwifQL/Bridges)
```swift
let user1 = User(email: "hello@gmail.com", name: "John")
let user2 = User(email: "byebye@gmail.com", name: "Amily")
let user3 = User(email: "trololo@gmail.com", name: "Trololo")
[user1, user2, user3].batchInsert(on: conn)
```
## Update

### General Update
SQL example
```sql
UPDATE "User" SET "name" = 'Mike'
```
SwifQL representation
```swift
SwifQL.update(User.table).set[items: User.$name == "Mike"]
```

### In Schema Update
SQL example
```sql
UPDATE "VIP"."User" SET "name" = 'Mike'
```
SwifQL representation
```swift
let vip = User.inSchema("VIP")
SwifQL.update(vip.table).set[items: vip.$name == "Mike"]
```

## Builders

For now there are only one implemented builder

### Select builder

`SwifQLSelectBuilder` - by using it you could easily build a select query but in multiple lines without carying about ordering.

```swift
let builder = SwifQLSelectBuilder()
builder.where(\User.id == 1)
builder.from(User.table)
builder.limit(1)
builder.select(User.table.*)
let query = builder.build()
return query.execute(on: req, as: .psql)
            .first(decoding: User.self)
            .unwrap(or: Abort(.notFound, reason: "User not found"))
```

So it will build query like: `SELECT "User".* FROM "User" WHERE "User"."id" = 1 LIMIT 1`.

As you can see you shouldn't worry about parts ordering, it will sort them the right way before building.

### More builders

Feel free to make your own builders and send pull request with it here!

Also more conveniences are available in [Bridges](https://github.com/SwifQL/Bridges) lib which is created on top of SwifQL and support all its flexibility

## More query examples

*Let's use `SwifQLSelectBuilder` for some next examples below, cause it's really convenient especially for complex queries.*

1. Let's imagine that you want to query count of users.

```swift
/// Just query
let query = SwifQL.select(Fn.count(\User.id) => "count").from(User.table)

/// Execution and decoding for Vapor
struct CountResult: Codable {
  let count: Int64
}
query.execute(on: req, as: .psql)
     .first(decoding: CountResult.self)
     .unwrap(or: Abort(.notFound)) // returns Future<CountResult>
```

Here you can see two interesting things: `Fn.count()` and `=> "count"`

`Fn` is a collection of function builders, so just call `Fn.` and take a look at the functions list on autocompletion.

`=>` uses for two things: 1) to write alias through `as` 2) to cast values to some other types

`// TBD: Expand list of examples`

## Aliasing
Use `=>` operator for that, e.g.:

If you want to write `SELECT "User"."email" as eml` then do it like this `SwifQL.select(\User.email => "eml")`

Or if to speak about table name aliasing:

If you want to reach `"User" as u` then do it like this `User.as("u")`

And then keypaths will work like

```swift
let u = User.as("u")
let emailKeypath = u.email
```

## Type casting
Use `=>` operator for that, e.g.:

If you want to write `SELECT "User"."email"::text` then do it like this `SwifQL.select(\User.email => .text)`

## Predicates
| Infix operator  | SQL equivalent |
| ------- | -------------- |
| > | > |
| >= | >= |
| < | < |
| <= | <= |
| == | = |
| == nil | IS NULL |
| != | != |
| != nil | IS NOT NULL |
| && | AND |

And also

`||` is for `OR`

`||>` is for `@>`

`<||` is for `<@`

> Please feel free to add more predicates in `Predicates.swift` 😉

## Operators
Please feel free to take a look at `Fn.Operator` enum in `Functions.swift`

## Functions
Please feel free to take a look at the list of function in `Functions.swift`

## Postgres JSON Object
You could build JSON objects by using `PostgresJsonObject`

SQL example
```sql
jsonb_build_object('id', "User"."id", 'email', "User"."email")
```
SwifQL representation
```swift
PgJsonObject().field(key: "id", value: \User.id).field(key: "email", value: \User.email)
```

## Postgres Array
You could build PostgreSQL arrays by using `PostgresArray`

SQL example
```sql
$$[]$$
ARRAY[]
ARRAY[1,2,3]
$$[]$$::uuid[]
ARRAY[]::text[]
```
SwifQL representation
```swift
PgArray(emptyMode: .dollar)
PgArray()
PgArray(1, 2, 3)
PgArray(emptyMode: .dollar) => .uuidArray
PgArray() => .textArray
```

Postgress range query examples
```swift
// var ingredients: [IngredientsEnum] 
SwifQL.select(FoodMenu.table.*).WHERE( \FoodMenu.$ingredients ||> [.tomato] )

// var ingredients: [String]
SwifQL.select(FoodMenu.table.*).WHERE( \FoodMenu.$ingredients ||> PgArray(["tomato"]) )

// var vendors: [UUID]
SwifQL.select(FoodMenu.table.*).WHERE( \FoodMenu.$vendors ||> PgArray([vendorUuid]) )
```

## Nesting array of objects inside of query result
Consider such response object you want to achieve:

```swift
struct Book {
  let title: String
  let authors: [Author]
}

struct Author {
  let name: String
}
```

you have to build it with use of subquery to dump Authors in JSON array and then attach them to result query. This will allow you to get all `Books` with their respective `Authors` 

This example uses Pivot table `BookAuthor` to join `Books` with their `Authors`

```swift
    let authors = SwifQL.select(Fn.coalesce(Fn.array_agg(Fn.to_jsonb(Author.table)), PgArray() => .jsonbArray))

    let query = SwifQLSelectBuilder()
    query.select(Book.table.*)

    query.from(Book.table)

    query.join(.left, BookAuthor.table, on: \Book.$id == \BookAuthor.$bookID)
    query.join(.left, Author.table, on: \Author.$id == \BookAuthor.$authorID)

    // then query.group(...) as required in your case
```

## FILTER
SQL example
```sql
COUNT("User"."id") FILTER (WHERE \User.isAdmin = TRUE) as "admins"
```
SwifQL representation
```swift
Fn.count(\User.id).filter(where: \User.isAdmin == true) => "admins"
```

## CASE ... WHEN ... THEN ... END
SQL example
```sql
CASE
  WHEN "User"."email" IS NULL
  THEN NULL
  ELSE "User"."email"
END
```
SwifQL representation
```swift
Case.when(\User.email == nil).then(nil).else(\User.email).end
// or as many cases as needed
Case.when(...).then(...).when(...).then(...).when(...).then(...).else(...).end
```

## Brackets

Yes, we really often use round brackets in our queries, e.g. in where clauses or in subqueries.

SwifQL provides you with `|` prefix and postfix operators which is representates `(` and `)`.

So it's easy to wrap some part of query into brackets, e.g.:
SQL example
```sql
"User.role" = 'admin' OR ("User.role" = 'user' AND "User"."age" >= 21)
```
SwifQL representation
```swift
let where = \User.role == .admin || |\User.role == .user && \User.age >= 21|
```

## Keypaths
| SQL | SwiftQL | SwiftQL + Bridges |
| ------- | -------------- | -------------- |
| `"User"` | `User.table` | `the same` |
| `"User" as u` | `User.as("u")` you could declare it as `let u = User.as("u")` | `the same` |
| `"User".*` | `User.table.*` | `the same` |
| `u.*` | `u.*` | `the same` |
| `"User"."email"` | `\User.email` | `\User.$email` |
| `u."email"` | `u.email` | `u.$email` |
| `"User"."jsonObject"->"jsonField"` | `\User.jsonObject.jsonField` | `only through full path for now` |
| `"User"."jsonObject"->"jsonField"` | `Path.Table("User").column("jsonObject", "jsonField")` | `the same` |

## Tests

For now tests coverage is maybe around 70%. If you have timе and interest please feel free to send pull requests with more tests.

You could find tests in `Tests` folder

### How it works under the hood

`SwifQL` object needed just to start writing query, but it's just an empty object that conforms to `SwifQLable`.

You can build your query with everything which conforms to `SwifQLable`, because `SwifQLable` is that very piece which will be used for concatenation to build a query.

> If you take a look at the lib's files you may realize that the most of files are just extensions to `SwifQLable`.

All available operators like `select`, `from`, `where`, and `orderBy` realized just as a function in `SwifQLable` extension and these functions always returns `SwifQLable` as a result. That's why you can write a query by calling `SwifQL.select().from().where().orderBy()` one by one. That's awesome cause it feels like writing a raw SQL, but it also gives you an ordering limitation, so if you write `SwifQL.select().where().from()` then you'll get wrong query as a result. But this limitation is resolved by using special builders, like `SwifQLSelectBuilder` (read about it later below).

So let's take a look how lib builds a simple `SELECT "User".* FROM "User" WHERE "User"."email" = 'john.smith@gmail.com'` query

First of all we should split query into the parts. Almost every word and punctuation here is a `SwifQLable` piece.

- `SELECT` is `Fn.Operator.select`
- ` ` is `Fn.Operator.space`
- `"User"` is `User.table`
- `.*` is `postfix operator .*`
- ` ` is `Fn.Operator.space`
- `FROM` is `Fn.Operator.from`
- `"User"` is `User.table`
- ` ` is `Fn.Operator.space`
- `WHERE` is `Fn.Operator.where`
- ` ` is `Fn.Operator.space`
- `"User"."email"` is `\User.email` keypath
- ` ` is `Fn.Operator.space`
- `==` is `infix operator ==`
- ` ` is `Fn.Operator.space`
- `'john.smith@gmail.com'` is `SwifQLPartUnsafeValue` (it means that this value should be passed as $1 to the database)

That's crazy, but awesome, right? 😄 But it's under the hood, so no worries! 😃 I just wanted to explain, that if you need something more than already provided then you'll be able to add needed operators/functions easily just by writing little extensions.

> And also there is no overhead, it works pretty fast, but I'd love to hear if you know how to make it faster.

This way gives you almost absolute flexibility in building queries. More than that as lib support `SQLDialect`'s it will build this query different way for PostgreSQL and MySQL, e.g.:

- PostgreSQL: `SELECT "User".* FROM "User" WHERE "User"."email" = 'john.smith@gmail.com'`
- MySQL: `SELECT User.* FROM User WHERE User.email = 'john.smith@gmail.com'`

## Contributing

Please feel free to contribute!


================================================
FILE: Sources/SwifQL/Alias.swift
================================================
//
//  Alias.swift
//  SwifQL
//
//  Created by Mihael Isaev on 19.04.2020.
//

import Foundation

public protocol AnyAlias {
    var name: String { get }
    var inputValue: Encodable? { get }
    var isChanged: Bool { get }
    func encode(to encoder: Encoder) throws
    func decode(from decoder: Decoder) throws
}

public protocol AliasRepresentable {
    associatedtype Value: Codable
    var alias: Alias<Value> { get }
}

@propertyWrapper
public final class Alias<Value>: AnyAlias, AliasRepresentable, ColumnRootNameable, Encodable where Value: Codable {
    public let name: String
    
    var outputValue: Value?
    public internal(set) var inputValue: Encodable?
    public var isChanged: Bool = false
    
    public var alias: Alias<Value> { self }
    public var columnName: String { alias.name }
    
    public var projectedValue: Alias<Value> { self }
    
    public var wrappedValue: Value {
        get {
            if let value = self.inputValue {
                return value as! Value
            } else if let value = self.outputValue {
                return value
            } else {
                fatalError("Cannot access field before it is initialized")
            }
        }
        set {
            self.inputValue = newValue
            self.isChanged = true
        }
    }
    
    public init(_ name: String) {
        self.name = name
    }
    
    /// See `Codable`
    
    public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        try container.encode(self.wrappedValue)
    }

    public func decode(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let valueType = Value.self as? _Optional.Type {
            if container.decodeNil() {
                self.wrappedValue = (valueType._none as! Value)
            } else {
                self.wrappedValue = try container.decode(Value.self)
            }
        } else {
            self.wrappedValue = try container.decode(Value.self)
        }
        self.isChanged = false
    }
}

protocol _Optional {
    static var _none: Any { get }
}

extension Optional: _Optional {
    static var _none: Any {
        return Self.none as Any
    }
}

// MARK: - KeyPath

protocol _AliasKeyPath {}

extension KeyPath: _AliasKeyPath where Value: AnyAlias {}

extension KeyPath: SwifQLable, CustomStringConvertible where Root: ColumnRoot, Value: ColumnRootNameable {
    public var parts: [SwifQLPart] {
        if let kp = self as? Keypathable {
            return Path.Schema(kp.schema).table(kp.table).column(Root.key(for: self)).parts
        }
        return [SwifQLPartAlias(Root.key(for: self))]
    }
}

// MARK: - Aliasable

public protocol Aliasable: ColumnRoot, Codable {
    init ()
}

extension Aliasable {
    var columns: [(String, AnyAlias)] {
        return Mirror(reflecting: self)
            .children
            .compactMap { child in
                guard let property = child.value as? AnyAlias else {
                    return nil
                }
                // remove underscore
                return (property.name, property)
            }
    }
    
    /// See `Codable`
    
    public init(from decoder: Decoder) throws {
        self.init()
        let container = try decoder.container(keyedBy: AliasCodingKey.self)
        try self.columns.forEach { label, property in
            let decoder = AliasContainerDecoder(container: container, key: .string(label))
            try property.decode(from: decoder)
        }
    }

    public func encode(to encoder: Encoder) throws {
        let container = encoder.container(keyedBy: AliasCodingKey.self)
        try self.columns.forEach { label, property in
            let encoder = ContainerEncoder(container: container, key: .string(label))
            try property.encode(to: encoder)
        }
    }
}

enum AliasCodingKey: CodingKey {
    case string(String)
    case int(Int)
    
    var stringValue: String {
        switch self {
        case .int(let int): return String(describing: int)
        case .string(let string): return string
        }
    }
    
    var intValue: Int? {
        switch self {
        case .int(let int): return int
        case .string(let string): return Int(string)
        }
    }
    
    init?(stringValue: String) {
        self = .string(stringValue)
    }
    
    init?(intValue: Int) {
        self = .int(intValue)
    }
}

private struct AliasContainerDecoder: Decoder, SingleValueDecodingContainer {
    let container: KeyedDecodingContainer<AliasCodingKey>
    let key: AliasCodingKey
    
    var codingPath: [CodingKey] {
        self.container.codingPath
    }
    
    var userInfo: [CodingUserInfoKey : Any] {
        [:]
    }
    
    func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> where Key : CodingKey {
        try self.container.nestedContainer(keyedBy: Key.self, forKey: self.key)
    }
    
    func unkeyedContainer() throws -> UnkeyedDecodingContainer {
        try self.container.nestedUnkeyedContainer(forKey: self.key)
    }
    
    func singleValueContainer() throws -> SingleValueDecodingContainer {
        self
    }
    
    func decode<T>(_ type: T.Type) throws -> T where T : Decodable {
        try self.container.decode(T.self, forKey: self.key)
    }
    
    func decodeNil() -> Bool {
        do {
            return try self.container.decodeNil(forKey: self.key)
        } catch {
            return true
        }
    }
}

private struct ContainerEncoder: Encoder, SingleValueEncodingContainer {
    var container: KeyedEncodingContainer<AliasCodingKey>
    let key: AliasCodingKey
    
    var codingPath: [CodingKey] {
        self.container.codingPath
    }
    
    var userInfo: [CodingUserInfoKey : Any] {
        [:]
    }
    
    func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key : CodingKey {
        var container = self.container
        return container.nestedContainer(keyedBy: Key.self, forKey: self.key)
    }
    
    func unkeyedContainer() -> UnkeyedEncodingContainer {
        var container = self.container
        return container.nestedUnkeyedContainer(forKey: self.key)
    }
    
    func singleValueContainer() -> SingleValueEncodingContainer {
        self
    }
    
    mutating func encode<T>(_ value: T) throws where T : Encodable {
        try self.container.encode(value, forKey: self.key)
    }
    
    mutating func encodeNil() throws {
        try self.container.encodeNil(forKey: self.key)
    }
}


================================================
FILE: Sources/SwifQL/Builders/CaseWhen.swift
================================================
//
//  SwifQLable+Case.swift
//  SwifQL
//
//  Created by Mihael Isaev on 15/02/2019.
//

import Foundation

public class Case {
    var parts: [SwifQLPart] = []
    
    public init (_ expression: SwifQLable? = nil) {
        parts.append(o: .case)
        if let expression = expression {
            parts.append(o: .space)
            parts.append(contentsOf: expression.parts)
        }
    }
    
    public static func when(_ expression: SwifQLable) -> Case {
        Case().when(expression)
    }
    
    public func when(_ expression: SwifQLable) -> Case {
        parts.appendSpaceIfNeeded()
        parts.append(o: .when)
        parts.append(o: .space)
        parts.append(contentsOf: expression.parts)
        return self
    }
    
    public func then(_ expression: SwifQLable?) -> Case {
        parts.appendSpaceIfNeeded()
        parts.append(o: .then)
        parts.append(o: .space)
        if let expression = expression {
            parts.append(contentsOf: expression.parts)
        } else {
            parts.append(o: .null)
        }
        return self
    }
    
    public func `else`(_ expression: SwifQLable?) -> Case {
        parts.appendSpaceIfNeeded()
        parts.append(o: .else)
        parts.append(o: .space)
        if let expression = expression {
            parts.append(contentsOf: expression.parts)
        } else {
            parts.append(o: .null)
        }
        return self
    }
    
    public var end: SwifQLable {
        parts.appendSpaceIfNeeded()
        parts.append(o: .end)
        return SwifQLableParts(parts: parts)
    }
}


================================================
FILE: Sources/SwifQL/Builders/Distinct.swift
================================================
//
//  Distinct.swift
//  SwifQL
//
//  Created by Mihael Isaev on 02/03/2019.
//

import Foundation

//MARK: DISTINCT

public class Distinct: SwifQLable {
    public var parts: [SwifQLPart]
    
    public convenience init (_ field: SwifQLable...) {
        self.init(field)
    }
    
    public init (_ fields: [SwifQLable]) {
        parts = []
        parts.append(o: .distinct)
        parts.append(o: .space)
        for (i, v) in fields.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
    }
    
    public convenience init (on field: SwifQLable...) {
        self.init(on: field)
    }
    
    public init (on fields: [SwifQLable]) {
        parts = []
        parts.append(o: .distinct)
        parts.append(o: .space)
        parts.append(o: .on)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        for (i, v) in fields.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        parts.append(o: .closeBracket)
    }
    
    public func andAlso(_ fields: SwifQLable...) -> Distinct {
        andAlso(fields)
    }
    
    public func andAlso(_ fields: [SwifQLable]) -> Distinct {
        parts.append(o: .space)
        for (i, v) in fields.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/GenericTableSelector.swift
================================================
//
//  GenericTableSelector.swift
//  SwifQL
//
//  Created by Mihael Isaev on 31.01.2020.
//

extension Table {
    public static var select: TableSelector<Self> { .init() }
}

public class TableSelector<T: Table>: SwifQLable {
    public var parts: [SwifQLPart] { build() }
    
    var columns: [String] = []
    var exceptColumns: [String] = []

    // MARK: Columns
    
    public func columns<A>(_ a: KeyPath<T, A>) -> Self where A: ColumnRepresentable {
        columns.append(T.key(for: a))
        return self
    }
    
    public func columns<A, B>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        return self
    }
    
    public func columns<A, B, C>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        return self
    }
    
    public func columns<A, B, C, D>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        return self
    }
    
    public func columns<A, B, C, D, E>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        return self
    }
    
    public func columns<A, B, C, D, E, F>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>,
        _ o: KeyPath<T, O>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable,
        O: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        columns.append(T.key(for: o))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>,
        _ o: KeyPath<T, O>,
        _ p: KeyPath<T, P>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable,
        O: ColumnRepresentable,
        P: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        columns.append(T.key(for: o))
        columns.append(T.key(for: p))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>,
        _ o: KeyPath<T, O>,
        _ p: KeyPath<T, P>,
        _ q: KeyPath<T, Q>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable,
        O: ColumnRepresentable,
        P: ColumnRepresentable,
        Q: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        columns.append(T.key(for: o))
        columns.append(T.key(for: p))
        columns.append(T.key(for: q))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>,
        _ o: KeyPath<T, O>,
        _ p: KeyPath<T, P>,
        _ q: KeyPath<T, Q>,
        _ r: KeyPath<T, R>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable,
        O: ColumnRepresentable,
        P: ColumnRepresentable,
        Q: ColumnRepresentable,
        R: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        columns.append(T.key(for: o))
        columns.append(T.key(for: p))
        columns.append(T.key(for: q))
        columns.append(T.key(for: r))
        return self
    }
    
    public func columns<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(
        _ a: KeyPath<T, A>,
        _ b: KeyPath<T, B>,
        _ c: KeyPath<T, C>,
        _ d: KeyPath<T, D>,
        _ e: KeyPath<T, E>,
        _ f: KeyPath<T, F>,
        _ g: KeyPath<T, G>,
        _ h: KeyPath<T, H>,
        _ i: KeyPath<T, I>,
        _ j: KeyPath<T, J>,
        _ k: KeyPath<T, K>,
        _ l: KeyPath<T, L>,
        _ m: KeyPath<T, M>,
        _ n: KeyPath<T, N>,
        _ o: KeyPath<T, O>,
        _ p: KeyPath<T, P>,
        _ q: KeyPath<T, Q>,
        _ r: KeyPath<T, R>,
        _ s: KeyPath<T, S>
    ) -> Self where
        A: ColumnRepresentable,
        B: ColumnRepresentable,
        C: ColumnRepresentable,
        D: ColumnRepresentable,
        E: ColumnRepresentable,
        F: ColumnRepresentable,
        G: ColumnRepresentable,
        H: ColumnRepresentable,
        I: ColumnRepresentable,
        J: ColumnRepresentable,
        K: ColumnRepresentable,
        L: ColumnRepresentable,
        M: ColumnRepresentable,
        N: ColumnRepresentable,
        O: ColumnRepresentable,
        P: ColumnRepresentable,
        Q: ColumnRepresentable,
        R: ColumnRepresentable,
        S: ColumnRepresentable {
        columns.append(T.key(for: a))
        columns.append(T.key(for: b))
        columns.append(T.key(for: c))
        columns.append(T.key(for: d))
        columns.append(T.key(for: e))
        columns.append(T.key(for: f))
        columns.append(T.key(for: g))
        columns.append(T.key(for: h))
        columns.append(T.key(for: i))
        columns.append(T.key(for: j))
        columns.append(T.key(for: k))
        columns.append(T.key(for: l))
        columns.append(T.key(for: m))
        columns.append(T.key(for: n))
        columns.append(T.key(for: o))
        columns.append(T.key(for: p))
        columns.append(T.key(for: q))
        columns.append(T.key(for: r))
        columns.append(T.key(for: s))
        return self
    }
    
    // MARK: Except columns
    
    public func exceptColumn<Column>(_ column: KeyPath<T, Column>) -> Self where Column: ColumnRepresentable {
        exceptColumns.append(T.key(for: column))
        return self
    }
    
    // MARK: Building
    
    private func build() -> [SwifQLPart] {
        var query = SwifQL
        if columns.count == 0 {
            if exceptColumns.count > 0 {
                var cols = T.init().columns.map { $0.name.label }
                if exceptColumns.count > 0 {
                    cols = cols.filter { !exceptColumns.contains($0) }
                }
                query = query.select(cols.map { Path.Table(T.tableName).column($0) })
            } else {
                query = query.select(T.table.*)
            }
        } else {
            var cols = columns
            if exceptColumns.count > 0 {
                cols = cols.filter { !exceptColumns.contains($0) }
            }
            query = query.select(cols.map { Path.Table(T.tableName).column($0) })
        }
        query = query.from(T.table)
        return query.parts
    }
}


================================================
FILE: Sources/SwifQL/Builders/NewColumn.swift
================================================
//
//  NewColumn.swift
//  
//
//  Created by Mihael Isaev on 26.01.2020.
//

import Foundation

public class NewColumn: SwifQLable {
    var name: String
    var type: Type
    var `default`: SwifQLable?
    var constraints: [SwifQLable] = []
    
    public init(_ name: String, _ type: Type) {
        self.name = name
        self.type = type
    }
    
    @discardableResult
    public func `default`(constant v: Any) -> Self {
        `default` = SwifQLableParts(parts: SwifQLPartSafeValue(v))
        return self
    }
    
    @discardableResult
    public func `default`(expression: SwifQLable) -> Self {
        `default` = expression
        return self
    }
    
    @discardableResult
    public func `default`(sequence name: String) -> Self {
        `default` = SwifQLableParts(parts: Op.custom(name))
        return self
    }
    
    @discardableResult
    public func constraint(expression: SwifQLable) -> Self {
        constraints.append(expression)
        return self
    }
    
    @discardableResult
    public func primaryKey() -> Self {
        constraints.append(SwifQL.primary.key)
        return self
    }
    
    @discardableResult
    public func unique() -> Self {
        constraints.append(SwifQL.unique)
        return self
    }
    
    @discardableResult
    public func notNull() -> Self {
        constraints.append(SwifQL.not.null)
        return self
    }
    
    @discardableResult
    public func check(name: String? = nil, _ expression: SwifQLable) -> Self {
        guard expression.parts.count > 0 else { return self }
        var parts: [SwifQLPart] = []
        if let name = name {
            parts.append(o: .constraint)
            parts.append(o: .space)
            parts.append(SwifQLPartColumn(name))
        }
        parts.appendSpaceIfNeeded()
        parts.append(o: .check)
        parts.append(o: .openBracket)
        parts.append(contentsOf: expression.parts)
        parts.append(o: .closeBracket)
        constraints.append(SwifQLableParts(parts: parts))
        return self
    }
    
    public var parts: [SwifQLPart] {
        var parts: [SwifQLPart] = []
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .custom(type.name))
        if let expression = `default` {
            parts.append(o: .space)
            parts.append(contentsOf: expression.parts)
        }
        constraints.forEach { expression in
            parts.append(o: .space)
            parts.append(contentsOf: expression.parts)
        }
        return parts
    }
}



================================================
FILE: Sources/SwifQL/Builders/PostgresArray.swift
================================================
//
//  PostgresArray.swift
//  SwifQL
//
//  Created by Mihael Isaev on 14/02/2019.
//

import Foundation

public typealias PgArray = PostgresArray

public struct PostgresArray: SwifQLable {
    public enum EmptyMode {
        case simple, dollar
    }
    
    public var parts: [SwifQLPart] = []
    
    public init (_ items: SwifQLable..., emptyMode: EmptyMode = .simple) {
        self.init(items, emptyMode: emptyMode)
    }
    
    public init (_ items: [SwifQLable], emptyMode: EmptyMode = .simple) {
        if items.count == 0 && emptyMode == .dollar {
            parts.append(o: .doubleDollar)
            parts.append(o: .openSquareBracket)
            parts.append(o: .closeSquareBracket)
            parts.append(o: .doubleDollar)
            return
        }
        parts.append(o: .array)
        parts.append(o: .openSquareBracket)
        for (i, v) in items.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        parts.append(o: .closeSquareBracket)
    }
}


================================================
FILE: Sources/SwifQL/Builders/PostgresJsonObject.swift
================================================
//
//  PostgresJsonObject.swift
//  SwifQL
//
//  Created by Mihael Isaev on 14/02/2019.
//

import Foundation

public typealias PgJsonObject = PostgresJsonObject

public class PostgresJsonObject: SwifQLable {
    private struct Field {
        enum KeyMode {
            case `default`, keyPath
        }
        let key: SwifQLable
        let mode: KeyMode
        let value: SwifQLable
    }
    
    private var fields: [Field] = []
    
    public var parts: [SwifQLPart] {
        var parts: [SwifQLPart] = []
        parts.appendSpaceIfNeeded()
        var body: [SwifQLPart] = []
        for (i, v) in fields.enumerated() {
            if i > 0 {
                body.append(o: .comma)
                body.append(o: .space)
            }
            switch v.mode {
            case .default:
                body.append(contentsOf: v.key.parts)
            case .keyPath:
                if let key = v.key as? SwifQLUniversalKeyPathSimple {
                    body.append(o: .custom(key.lastPath.singleQuotted))
                } else {
                    body.append(o: .custom(String(describing: v.key).singleQuotted))
                }
            }
            body.append(o: .comma)
            body.append(o: .space)
            body.append(contentsOf: v.value.parts)
        }
        return Fn.build(.jsonb_build_object, body: body).parts
    }
    
    public init () {}
    
    public func field(key: SwifQLable, value: SwifQLable) -> PostgresJsonObject {
        let field = Field(key: key, mode: .default, value: value)
        fields.append(field)
        return self
    }
    
    public func field(keyPathAsKey: SwifQLable, value: SwifQLable) -> PostgresJsonObject {
        let field = Field(key: keyPathAsKey, mode: .keyPath, value: value)
        fields.append(field)
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/QueryBuilder.swift
================================================
//
//  QueryBuilder.swift
//  SwifQLCore
//
//  Created by Mihael Isaev on 19.12.2019.
//

import Foundation

public protocol QueryBuilderItemable {
    var values: [SwifQLable] { get }
}
public struct QueryBuilderItem: SwifQLable {
    public let parts: [SwifQLPart]
    public let values: [SwifQLable]
    public init (_ values: [SwifQLable]? = nil) {
        var parts: [SwifQLPart] = []
        if let values = values {
            values.forEach {
                parts.append(contentsOf: $0.parts)
            }
        }
        self.parts = parts
        self.values = values ?? []
    }
}
@resultBuilder public struct QueryBuilder {
    public typealias Block = () -> SwifQLable
    
    /// Builds an empty view from an block containing no statements, `{ }`.
    public static func buildBlock() -> SwifQLable { QueryBuilderItem() }
    
    /// Passes a single view written as a child view (e..g, `{ Text("Hello") }`) through unmodified.
    public static func buildBlock(_ attr: SwifQLable) -> SwifQLable {
        QueryBuilderItem([attr])
    }
    
    /// Passes a single view written as a child view (e..g, `{ Text("Hello") }`) through unmodified.
    public static func buildBlock(_ attrs: SwifQLable...) -> SwifQLable {
        QueryBuilderItem(attrs)
    }
    
    /// Passes a single view written as a child view (e..g, `{ Text("Hello") }`) through unmodified.
    public static func buildBlock(_ attrs: [SwifQLable]) -> SwifQLable {
        QueryBuilderItem(attrs)
    }
    
    /// Provides support for "if" statements in multi-statement closures, producing an `Optional` view
    /// that is visible only when the `if` condition evaluates `true`.
    public static func buildIf(_ content: SwifQLable?) -> SwifQLable {
        guard let content = content else { return QueryBuilderItem() }
        return QueryBuilderItem([content])
    }
    
    /// Provides support for "if" statements in multi-statement closures, producing
    /// ConditionalContent for the "then" branch.
    public static func buildEither(first: SwifQLable) -> SwifQLable {
        QueryBuilderItem([first])
    }

    /// Provides support for "if-else" statements in multi-statement closures, producing
    /// ConditionalContent for the "else" branch.
    public static func buildEither(second: SwifQLable) -> SwifQLable {
        QueryBuilderItem([second])
    }
}


================================================
FILE: Sources/SwifQL/Builders/Schema/CreateSchemaBuilder.swift
================================================
//
//  CreateSchemaBuilder.swift
//  SwifQL
//
//  Created by Mihael Isaev on 12.04.2020.
//

public class CreateSchemaBuilder<Schema: Schemable>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.create.schema
        if shouldCheckIfNotExists {
            query = query.if.not.exists
        }
        query = query[any: Path.Schema(Schema.schemaName)]
        return query.parts
    }
    
    var shouldCheckIfNotExists = false
    
    public init () {}
    
    public func checkIfNotExists() -> Self {
        shouldCheckIfNotExists = true
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/Schema/DropSchemaBuilder.swift
================================================
//
//  DropSchemaBuilder.swift
//  SwifQL
//
//  Created by Mihael Isaev on 12.04.2020.
//

public class DropSchemaBuilder<Schema: Schemable>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.drop.schema
        if shouldCheckIfExists {
            query = query.if.exists
        }
        query = query[any: Path.Schema(Schema.schemaName)]
        return query.parts
    }
    
    var shouldCheckIfExists = false
    
    public init () {}
    
    public func checkIfExists() -> Self {
        shouldCheckIfExists = true
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/Schema/UpdateSchemaChangeOwner.swift
================================================
//
//  UpdateSchemaChangeOwner.swift
//  SwifQL
//
//  Created by Mihael Isaev on 12.04.2020.
//

public class UpdateSchemaChangeOwner<Schema: Schemable>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.alter.schema
        query = query[any: Path.Schema(Schema.schemaName)]
        query = query.owner.to
        query = query[any: Path.Schema(newOwner)]
        return query.parts
    }
    
    var newOwner = ""
    
    public init () {}
    
    public func newOwner(_ name: String) -> Self {
        newOwner = name
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/Schema/UpdateSchemaRename.swift
================================================
//
//  UpdateSchemaRename.swift
//  SwifQL
//
//  Created by Mihael Isaev on 12.04.2020.
//

public class UpdateSchemaRenameBuilder<Schema: Schemable>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.alter.schema
        query = query[any: Path.Schema(Schema.schemaName)]
        query = query.rename.to
        query = query[any: Path.Schema(newName)]
        return query.parts
    }
    
    var newName = ""
    
    public init () {}
    
    public func newName(_ name: String) -> Self {
        newName = name
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/SwifQLJoinBuilder.swift
================================================
//
//  SwifQLJoinBuilder.swift
//  App
//
//  Created by Mihael Isaev on 22/02/2019.
//

import Foundation

public struct JoinMode {
    let parts: [SwifQLPartOperator]
    
    public init (_ parts: SwifQLPartOperator...) {
        self.parts = parts
    }
    
    public init (_ parts: [SwifQLPartOperator]) {
        self.parts = parts
    }
    
    public static var none: JoinMode { .init(.join) }
    
    public static var left: JoinMode { .init(.left, .space, .join) }
    public static var leftLateral: JoinMode { .init(.left, .space, .join, .space, .lateral) }
    
    public static var leftOuter: JoinMode { .init(.left, .space, .outer, .space, .join) }
    public static var leftOuterLateral: JoinMode { .init(.left, .space, .outer, .space, .join, .space, .lateral) }

    public static var right: JoinMode { .init(.right, .space, .join) }
    public static var rightLateral: JoinMode { .init(.right, .space, .join, .space, .lateral) }

    public static var rightOuter: JoinMode { .init(.right, .space, .outer, .space, .join) }
    public static var rightOuterLateral: JoinMode { .init(.right, .space, .outer, .space, .join, .space, .lateral) }

    public static var inner: JoinMode { .init(.inner, .space, .join) }
    public static var outer: JoinMode { .init(.outer, .space, .join) }
    
    public static var cross: JoinMode { .init(.cross, .space, .join) }
    public static var crossLateral: JoinMode { .init(.cross, .space, .join, .space, .lateral) }
}

public struct SwifQLJoinBuilder: SwifQLable {
    let mode: JoinMode
    let table: SwifQLable
    let predicates: SwifQLable?
    
    public init (_ mode: JoinMode? = nil, _ table: SwifQLable, on predicates: SwifQLable? = nil) {
        self.mode = mode ?? .none
        self.table = table
        self.predicates = predicates
    }
    
    public var parts: [SwifQLPart] {
        var parts: [SwifQLPart] = []
        parts.appendSpaceIfNeeded()
        parts.append(contentsOf: mode.parts)
        parts.append(o: .space)
        parts.append(contentsOf: table.parts)
        if let predicates = predicates {
            parts.append(o: .space)
            parts.append(o: .on)
            parts.append(o: .space)
            parts.append(contentsOf: predicates.parts)
        }
        return parts
    }
}


================================================
FILE: Sources/SwifQL/Builders/SwifQLSelectBuilder.swift
================================================
//
//  SwifQLSelectBuilder.swift
//  App
//
//  Created by Mihael Isaev on 22/02/2019.
//

import Foundation

public class SwifQLSelectBuilder: QueryBuilderable {
    var select: [SwifQLable] = []
    var froms: [SwifQLable] = []
    
    public var queryParts = QueryParts()
    
    public init() {}
    
    public func copy() -> SwifQLSelectBuilder {
        let copy = SwifQLSelectBuilder()
        
        copy.select = select
        copy.froms = froms
        copy.queryParts = queryParts.copy()
        
        return copy
    }
    
    // MARK: Select
    
    @discardableResult
    public func select(_ item: SwifQLable...) -> SwifQLSelectBuilder {
        select(item)
    }
    
    @discardableResult
    public func select(_ items: [SwifQLable]) -> SwifQLSelectBuilder {
        select.append(contentsOf: items)
        return self
    }
    
    // MARK: From
    
    @discardableResult
    public func from(_ item: SwifQLable...) -> SwifQLSelectBuilder {
        from(item)
    }
    
    @discardableResult
    public func from(_ items: [SwifQLable]) -> SwifQLSelectBuilder {
        froms.append(contentsOf: items)
        return self
    }
    
    public func build() -> SwifQLable {
        var query = SwifQL.select(select)
        if froms.count > 0 {
            query = query.from(froms)
        }
        return queryParts.appended(to: query)
    }
}


================================================
FILE: Sources/SwifQL/Builders/Table/CreateTableBuilder.swift
================================================
//
//  CreateTableBuilder.swift
//  SwifQL
//
//  Created by Mihael Isaev on 29.01.2020.
//

public class CreateTableBuilder<T: Table>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.create.table
        if shouldCheckIfNotExists {
            query = query.if.not.exists
        }
        let table = Path.Schema(schemaName).table(T.tableName)
        query = query[any: table].newColumns(columns)
        return query.parts
    }
    
    var columns: [NewColumn] = []
    var shouldCheckIfNotExists = false
    var schemaName: String?
    
    public init (schema: Schemable.Type? = nil) {
        self.schemaName = schema?.schemaName ?? (T.self as? Schemable.Type)?.schemaName
    }
    
    public init (schema: String) {
        self.schemaName = schema
    }
    
    public func column(_ newColumn: NewColumn) -> Self {
        columns.append(newColumn)
        return self
    }
    
    // MARK: KeyPath
    
    public func column<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`) -> Self where V: ColumnRepresentable {
        column(keyPath, type: type, default: nil, constraints: [])
    }
    
    public func column<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`, _ constraints: Constraint...) -> Self where V: ColumnRepresentable {
        column(keyPath, type: type, default: nil, constraints: constraints)
    }
    
    public func column<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`, _ `default`: ColumnDefault, _ constraints: Constraint...) -> Self where V: ColumnRepresentable {
        column(keyPath, type: type, default: `default`, constraints: constraints)
    }
    
    public func column<V>(_ keyPath: KeyPath<T, V>, type: SwifQL.`Type`, `default`: ColumnDefault?, constraints: [Constraint]) -> Self where V: ColumnRepresentable {
        column(T.key(for: keyPath), type: type, default: `default`, constraints: constraints)
    }
    
    // MARK: String
    
    public func column(_ name: String, _ type: SwifQL.`Type`) -> Self {
        column(name, type: type, default: nil, constraints: [])
    }
    
    public func column(_ name: String, _ type: SwifQL.`Type`, _ constraints: Constraint...) -> Self {
        column(name, type: type, default: nil, constraints: constraints)
    }
    
    public func column(_ name: String, _ type: SwifQL.`Type`, _ `default`: ColumnDefault, _ constraints: Constraint...) -> Self {
        column(name, type: type, default: `default`, constraints: constraints)
    }
    
    public func column(_ name: String, type: SwifQL.`Type`, `default`: ColumnDefault?, constraints: [Constraint]) -> Self {
        let newColumn = NewColumn(name, type)
        if let expression = `default`?.query {
            newColumn.default(expression: expression)
        }
        constraints.forEach {
            newColumn.constraint(expression: $0.query)
        }
        columns.append(newColumn)
        return self
    }
    
    public func checkIfNotExists() -> Self {
        shouldCheckIfNotExists = true
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/Table/DropTableBuilder.swift
================================================
//
//  DropTableBuilder.swift
//  SwifQL
//
//  Created by Mihael Isaev on 29.01.2020.
//

public class DropTableBuilder<T: Table>: SwifQLable {
    public var parts: [SwifQLPart] {
        var query = SwifQL.drop.table
        if shouldCheckIfExists {
            query = query.if.exists
        }
        query = query[any: Path.Table(T.tableName)]
        return query.parts
    }
    
    var shouldCheckIfExists = false
    
    public init () {}
    
    public func checkIfExists() -> Self {
        shouldCheckIfExists = true
        return self
    }
}


================================================
FILE: Sources/SwifQL/Builders/Table/UpdateTableBuilder.swift
================================================
//
//  UpdateTableBuilder.swift
//  SwifQL
//
//  Created by Mihael Isaev on 29.01.2020.
//

public class UpdateTableBuilder<T: Table>: SwifQLable {
    public var parts: [SwifQLPart] {
        let table = Path.Schema(schemaName).table(T.tableName)
        var parts: [SwifQLPart] = []
        if combinedAlterActions.count > 0 {
            var combinedParts = SwifQL.alter.table[any: table].parts
            combinedParts.append(o: .space)
            combinedAlterActions.enumerated().forEach { i, action in
                if i > 0 {
                    combinedParts.append(o: .comma)
                    combinedParts.append(o: .space)
                }
                combinedParts.append(contentsOf: action)
            }
            combinedParts.append(o: .semicolon)
            parts.append(contentsOf: combinedParts)
        }
        standAloneAlterActions.forEach { action in
            var standAloneParts = SwifQL.alter.table[any: table].parts
            standAloneParts.append(o: .space)
            standAloneParts.append(contentsOf: action)
            standAloneParts.append(o: .semicolon)
            parts.append(contentsOf: standAloneParts)
        }
        otherActions.forEach { action in
            var actionParts = action
            actionParts.append(o: .semicolon)
            parts.append(contentsOf: actionParts)
        }
        if let newName = renameTableTo {
            var renameParts = SwifQL.alter.table[any: table].parts
            renameParts.append(o: .space)
            renameParts.append(o: .rename)
            renameParts.append(o: .space)
            renameParts.append(o: .to)
            renameParts.append(o: .space)
            renameParts.append(SwifQLPartColumn(newName))
            renameParts.append(o: .semicolon)
            parts.append(contentsOf: renameParts)
        }
        return parts
    }
    
    var combinedAlterActions: [[SwifQLPart]] = []
    var standAloneAlterActions: [[SwifQLPart]] = []
    var otherActions: [[SwifQLPart]] = []
    var renameTableTo: String?
    var schemaName: String?
    
    public init (schema: Schemable.Type? = nil) {
        self.schemaName = schema?.schemaName ?? (T.self as? Schemable.Type)?.schemaName
    }
    
    public init (schema: String) {
        self.schemaName = schema
    }
    
    // MARK: - RENAME TABLE
    
    /// For changing the table name.
    public func renameTable(to: String) -> Self {
        renameTableTo = to
        return self
    }
    
    // MARK: - ADD COLUMN
    
    public func addColumn(_ newColumn: NewColumn) -> Self {
        var parts: [SwifQLPart] = []
        parts.append(o: .add)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(contentsOf: newColumn.parts)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: KeyPath
    
    /// Adds a new column to a table.
    public func addColumn<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`, checkIfNotExists: Bool = false) -> Self where V: ColumnRepresentable {
        addColumn(keyPath, type: type, default: nil, checkIfNotExists: checkIfNotExists, constraints: [])
    }
    
    /// Adds a new column to a table.
    public func addColumn<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`, checkIfNotExists: Bool = false, _ constraints: Constraint...) -> Self where V: ColumnRepresentable {
        addColumn(keyPath, type: type, default: nil, checkIfNotExists: checkIfNotExists, constraints: constraints)
    }
    
    /// Adds a new column to a table.
    public func addColumn<V>(_ keyPath: KeyPath<T, V>, _ type: SwifQL.`Type`, _ `default`: ColumnDefault, checkIfNotExists: Bool = false, _ constraints: Constraint...) -> Self where V: ColumnRepresentable {
        addColumn(keyPath, type: type, default: `default`, checkIfNotExists: checkIfNotExists, constraints: constraints)
    }
    
    /// Adds a new column to a table.
    public func addColumn<V>(_ keyPath: KeyPath<T, V>, type: SwifQL.`Type`, `default`: ColumnDefault?, checkIfNotExists: Bool = false, constraints: [Constraint]) -> Self where V: ColumnRepresentable {
        addColumn(T.key(for: keyPath), type: type, default: `default`, checkIfNotExists: checkIfNotExists, constraints: constraints)
    }
    
    // MARK: String
    
    /// Adds a new column to a table.
    public func addColumn(_ name: String, _ type: SwifQL.`Type`, checkIfNotExists: Bool = false) -> Self {
        addColumn(name, type: type, default: nil, checkIfNotExists: checkIfNotExists, constraints: [])
    }
    
    /// Adds a new column to a table.
    public func addColumn(_ name: String, _ type: SwifQL.`Type`, checkIfNotExists: Bool = false, _ constraints: Constraint...) -> Self {
        addColumn(name, type: type, default: nil, checkIfNotExists: checkIfNotExists, constraints: constraints)
    }
    
    /// Adds a new column to a table.
    public func addColumn(_ name: String, _ type: SwifQL.`Type`, _ `default`: ColumnDefault, checkIfNotExists: Bool = false, _ constraints: Constraint...) -> Self {
        addColumn(name, type: type, default: `default`, checkIfNotExists: checkIfNotExists, constraints: constraints)
    }
    
    /// Adds a new column to a table.
    public func addColumn(_ name: String, type: SwifQL.`Type`, `default`: ColumnDefault?, checkIfNotExists: Bool = false, constraints: [Constraint]) -> Self {
        var parts: [SwifQLPart] = []
        parts.append(o: .add)
        parts.append(o: .space)
        parts.append(o: .column)
        if checkIfNotExists {
            parts.append(o: .space)
            parts.append(o: .if)
            parts.append(o: .space)
            parts.append(o: .not)
            parts.append(o: .space)
            parts.append(o: .exists)
        }
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .custom(type.name))
        if let expression = `default` {
            parts.append(o: .space)
            parts.append(contentsOf: expression.query.parts)
        }
        constraints.forEach { expression in
            parts.append(o: .space)
            parts.append(contentsOf: expression.query.parts)
        }
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - DROP COLUMN
    
    /// For dropping a table column.
    /// The constraints and indexes imposed on the columns will also be dropped.
    ///
    /// You should use "string" table names instead of KeyPaths to keep consistency with previous migrations.
    ///
    /// Usage:
    ///
    /// ```swift
    /// .dropColumn(\User.$name)
    /// .dropColumn(\User.$surname, checkIfExists: true) // default `false`
    /// .dropColumn(\User.$createdAt, cascade: true) // default `false`
    /// ```
    public func dropColumn<V>(_ keyPath: KeyPath<T, V>, checkIfExists: Bool = false, cascade: Bool = false)  -> Self where V: ColumnRepresentable {
        dropColumn(T.key(for: keyPath), checkIfExists: checkIfExists, cascade: cascade)
    }
    
    /// For dropping a table column.
    /// The constraints and indexes imposed on the columns will also be dropped.
    ///
    /// Usage:
    ///
    /// ```swift
    /// .dropColumn("abc")
    /// .dropColumn("xyz", checkIfExists: true) // default `false`
    /// .dropColumn("qwe", cascade: true) // default `false`
    /// ```
    public func dropColumn(_ name: String, checkIfExists: Bool = false, cascade: Bool = false) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .drop)
        parts.append(o: .space)
        parts.append(o: .column)
        if checkIfExists {
            parts.append(o: .space)
            parts.append(o: .if)
            parts.append(o: .space)
            parts.append(o: .exists)
        }
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        if cascade {
            parts.append(o: .space)
            parts.append(o: .cascade)
        }
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - SET DEFAULT
    
    /// Use for adding/changing the default value for a column.
    public func setDefault<V>(_ keyPath: KeyPath<T, V>, constant v: Any)  -> Self where V: ColumnRepresentable {
        setDefault(T.key(for: keyPath), constant: v)
    }
    
    /// Use for adding/changing the default value for a column.
    public func setDefault<V>(_ keyPath: KeyPath<T, V>, expression: SwifQLable)  -> Self where V: ColumnRepresentable {
        setDefault(T.key(for: keyPath), expression: expression)
    }
    
    /// Use for adding/changing the default value for a column.
    public func setDefault<V>(_ keyPath: KeyPath<T, V>, sequence name: String)  -> Self where V: ColumnRepresentable {
        setDefault(T.key(for: keyPath), sequence: name)
    }
    
    /// Use for adding/changing the default value for a column.
    public func setDefault(_ name: String, constant v: Any) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .set)
        parts.append(o: .space)
        parts.append(o: .default)
        parts.append(o: .space)
        parts.append(SwifQLPartSafeValue(v))
        combinedAlterActions.append(parts)
        return self
    }
    
    /// Use for adding/changing the default value for a column.
    public func setDefault(_ name: String, expression: SwifQLable) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .set)
        parts.append(o: .space)
        parts.append(o: .default)
        parts.append(o: .space)
        parts.append(contentsOf: expression.parts)
        combinedAlterActions.append(parts)
        return self
    }
    
    /// Use for adding/changing the default value for a column.
    public func setDefault(_ name: String, sequence: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .set)
        parts.append(o: .space)
        parts.append(o: .default)
        parts.append(o: .space)
        parts.append(Op.custom(sequence))
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - DROP DEFAULT
    
    /// Use for removing the default value for a column.
    public func dropDefault<V>(_ keyPath: KeyPath<T, V>)  -> Self where V: ColumnRepresentable {
        dropDefault(T.key(for: keyPath))
    }
    
    /// Use for removing the default value for a column.
    public func dropDefault(_ name: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .drop)
        parts.append(o: .space)
        parts.append(o: .default)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - SET NOT NULL
    
    /// Use for removing NOT NULL mark for a column.
    public func setNotNull<V>(_ keyPath: KeyPath<T, V>)  -> Self where V: ColumnRepresentable {
        setNotNull(T.key(for: keyPath))
    }
    
    /// Use for removing NOT NULL mark for a column.
    public func setNotNull(_ name: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .set)
        parts.append(o: .space)
        parts.append(o: .not)
        parts.append(o: .space)
        parts.append(o: .null)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - DROP NOT NULL
    
    /// Use for removing NOT NULL mark for a column.
    public func dropNotNull<V>(_ keyPath: KeyPath<T, V>)  -> Self where V: ColumnRepresentable {
        dropNotNull(T.key(for: keyPath))
    }
    
    /// Use for removing NOT NULL mark for a column.
    public func dropNotNull(_ name: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .alter)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .drop)
        parts.append(o: .space)
        parts.append(o: .not)
        parts.append(o: .space)
        parts.append(o: .null)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - RENAME COLUMN
    
    /// For changing the table name or a column name.
    public func renameColumn<V>(_ keyPath: KeyPath<T, V>, to: String)  -> Self where V: ColumnRepresentable {
        renameColumn(T.key(for: keyPath), to: to)
    }
    
    /// For changing the table name or a column name.
    public func renameColumn(_ name: String, to: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .rename)
        parts.append(o: .space)
        parts.append(o: .column)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        parts.append(o: .space)
        parts.append(o: .to)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(to))
        standAloneAlterActions.append(parts)
        return self
    }
    
    // MARK: - DROP CONSTRAINT
    
    /// Use for dropping a table constraint.
    public func dropConstraint(_ name: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .drop)
        parts.append(o: .space)
        parts.append(o: .constraint)
        parts.append(o: .space)
        parts.append(SwifQLPartColumn(name))
        otherActions.append(parts)
        return self
    }
    
    // MARK: - ADD UNIQUE
    
    /// Use to add UNIQUE mark to one or several columns.
    public func addUnique(to columns: String...) -> Self {
        guard columns.count > 0 else { return self }
        var parts = SwifQL.parts
        parts.append(o: .add)
        parts.append(o: .space)
        parts.append(o: .unique)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        columns.enumerated().forEach { i, name in
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(SwifQLPartColumn(name))
        }
        parts.append(o: .closeBracket)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - ADD PRIMARY KEY
    
    /// Use to add PRIMARY KEY mark to one or several columns.
    public func addPrimaryKey(to columns: String...) -> Self {
        guard columns.count > 0 else { return self }
        var parts = SwifQL.parts
        parts.append(o: .add)
        parts.append(o: .space)
        parts.append(o: .primary)
        parts.append(o: .space)
        parts.append(o: .key)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        columns.enumerated().forEach { i, name in
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(SwifQLPartColumn(name))
        }
        parts.append(o: .closeBracket)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - DROP INDEX
    
    /// Drops index by its name.
    public func dropIndex(schema: String? = nil, name: String) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .drop)
        parts.append(o: .space)
        parts.append(o: .index)
        parts.append(o: .space)
        if let schema = schema {
            parts.append(SwifQLPartColumn(schema))
            parts.append(o: .period)
        }
        parts.append(SwifQLPartColumn(name))
        otherActions.append(parts)
        return self
    }
    
    // MARK: - CREATE INDEX
    
    /// Creates index for one or several columns.
    public func createIndex(unique: Bool = false, name: String? = nil, items: IndexItem..., type: IndexType? = nil, where condition: SwifQLable? = nil) -> Self {
        createIndex(unique: unique, name: name, items: items, type: type, where: condition)
    }
    
    /// Creates index for one or several columns.
    public func createIndex(unique: Bool = false, name: String? = nil, items: [IndexItem], type: IndexType? = nil, where condition: SwifQLable? = nil) -> Self {
        guard items.count > 0 else { return self }
        var parts = SwifQL.parts
        parts.append(o: .create)
        if unique {
            parts.append(o: .space)
            parts.append(o: .unique)
        }
        parts.append(o: .space)
        parts.append(o: .index)
        if let name = name {
            parts.append(o: .space)
            parts.append(SwifQLPartColumn(name))
        }
        parts.append(o: .space)
        parts.append(o: .on)
        parts.append(o: .space)
        parts.append(contentsOf: Path.Schema(schemaName).table(T.tableName).parts)
        if let type = type {
            parts.append(o: .space)
            parts.append(o: .using)
            parts.append(o: .space)
            parts.append(contentsOf: type.parts)
            parts.append(o: .space)
        }
        parts.append(o: .openBracket)
        items.enumerated().forEach { i, item in
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: item.parts)
        }
        parts.append(o: .closeBracket)
        if let condition = condition {
            parts.append(o: .space)
            parts.append(o: .where)
            parts.append(o: .space)
            parts.append(contentsOf: condition.parts)
        }
        otherActions.append(parts)
        return self
    }
    
    // MARK: - ADD CHECK
    
    /// A check constraint helps in validating the records that are being inserted into a table.
    /// We can do this by combining the ALTER TABLE command with the ADD CHECK statement.
    public func addCheck(constraintName: String? = nil, _ expression: SwifQLable) -> Self {
        var parts = SwifQL.parts
        parts.append(o: .add)
        if let constraintName = constraintName {
            parts.append(o: .space)
            parts.append(o: .constraint)
            parts.append(o: .space)
            parts.append(SwifQLPartColumn(constraintName))
        }
        parts.append(o: .space)
        parts.append(o: .check)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        parts.append(contentsOf: expression.parts)
        parts.append(o: .closeBracket)
        combinedAlterActions.append(parts)
        return self
    }
    
    // MARK: - ADD FOREIGN KEY
    
    public func addForeignKey(column: String, constraintName: String? = nil, schema: String? = nil, table: String, columns: String..., onDelete: ReferentialAction? = nil, onUpdate: ReferentialAction? = nil) -> Self {
        addForeignKey(column: column, constraintName: constraintName, schema: schema, table: table, columns: columns, onDelete: onDelete, onUpdate: onUpdate)
    }
    
    public func addForeignKey(column: String, constraintName: String? = nil, schema: String? = nil, table: String, columns: [String], onDelete: ReferentialAction? = nil, onUpdate: ReferentialAction? = nil) -> Self {
        guard columns.count > 0 else { return self }
        var parts = SwifQL.parts
        parts.append(o: .add)
        if let constraintName = constraintName {
            parts.append(o: .space)
            parts.append(o: .constraint)
            parts.append(o: .space)
            parts.append(SwifQLPartColumn(constraintName))
        }
        parts.append(o: .space)
        parts.append(o: .foreign)
        parts.append(o: .space)
        parts.append(o: .key)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        parts.append(SwifQLPartColumn(column))
        parts.append(o: .closeBracket)
        parts.append(o: .space)
        parts.append(o: .references)
        parts.append(o: .space)
        parts.append(SwifQLPartTable(schema: schema, table: table))
        parts.append(o: .openBracket)
        columns.enumerated().forEach { i, name in
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(SwifQLPartColumn(name))
        }
        parts.append(o: .closeBracket)
        if let action = onDelete {
            parts.append(o: .space)
            parts.append(o: .on)
            parts.append(o: .space)
            parts.append(o: .delete)
            parts.append(o: .space)
            parts.append(contentsOf: action.parts)
        }
        if let action = onUpdate {
            parts.append(o: .space)
            parts.append(o: .on)
            parts.append(o: .space)
            parts.append(o: .update)
            parts.append(o: .space)
            parts.append(contentsOf: action.parts)
        }
        combinedAlterActions.append(parts)
        return self
    }
    
    // TODO: https://www.postgresql.org/docs/current/sql-altertable.html
    
    // MARK: - SET STATISTICS
    
    /// For setting the statistics-gathering target for each column for ANALYZE operations.
    
    // MARK: - SET STORAGE
    
    /// For setting the mode of storage for a column.
    /// This will determine where the column is held, whether inline, or in a supplementary table.
    
    // MARK: - SET WITHOUT OIDS
    
    /// Use for removing the old column of the table.
    
    // MARK: - OWNER
    
    /// For changing the owner of a table, sequence, index or a view to a certain user.
    
    // MARK: - CLUSTER
    
    /// For marking a table to be used for carrying out future cluster operations.
}


================================================
FILE: Sources/SwifQL/Builders/Union.swift
================================================
//
//  Union.swift
//  SwifQL
//
//  Created by Taylor McIntyre on 2020-01-15.
//

import Foundation

//MARK: UNION

public class Union: SwifQLable {
    public var parts: [SwifQLPart]
    
    public convenience init (_ selection: SwifQLable...) {
        self.init(selection)
    }
    
    public init (_ selections: [SwifQLable]) {
        parts = [SwifQLPartOperator.openBracket]
        for (i, v) in selections.enumerated() {
            if i > 0 {
                parts.append(o: .space)
                parts.append(o: .union)
                parts.append(o: .space)
                parts.append(o: .openBracket)
            }
            parts.append(contentsOf: v.parts)
            parts.append(o: .closeBracket)
        }
    }
}


================================================
FILE: Sources/SwifQL/Builders/With.swift
================================================
//
//  With.swift
//  SwifQL
//
//  Created by Taylor McIntyre on 2020-01-16.
//

import Foundation

//MARK: WITH

public class With: SwifQLable {
    public var parts: [SwifQLPart]
    
    public init(_ table: SwifQLable, columns: [SwifQLable] = [], _ query: SwifQLable) {
        parts = table.parts
        if !columns.isEmpty {
            parts.append(o: .space)
            parts.append(o: .openBracket)
            for (i, v) in columns.enumerated() {
                if i > 0 {
                    parts.append(o: .comma)
                    parts.append(o: .space)
                }
                parts.append(contentsOf: v.parts)
            }
            parts.append(o: .closeBracket)
        }
        parts.append(o: .space)
        parts.append(o: .as)
        parts.append(o: .space)
        parts.append(o: .openBracket)
        parts.append(contentsOf: query.parts)
        parts.append(o: .closeBracket)
    }
}


================================================
FILE: Sources/SwifQL/Codable.swift
================================================
//
//  Codable.swift
//  SwifQL
//
//  Created by Mihael Isaev on 25.04.2020.
//

import Foundation

public protocol SwifQLCodable: Codable, SwifQLable {}

extension SwifQLCodable {
    public var parts: [SwifQLPart] { [SwifQLPartUnsafeValue(self)] }
}

public protocol SwifQLEncodable: Encodable, SwifQLable {}

extension SwifQLEncodable {
    public var parts: [SwifQLPart] { [SwifQLPartUnsafeValue(self)] }
}

extension Array: SwifQLCodable where Element: SwifQLCodable {}


================================================
FILE: Sources/SwifQL/Column.swift
================================================
//
//  Column.swift
//  SwifQL
//
//  Created by Mihael Isaev on 26.01.2020.
//

import Foundation

public protocol AnyColumn {
    var name: String { get }
    var type: SwifQL.`Type` { get }
    var `default`: ColumnDefault? { get }
    var constraints: [Constraint] { get }
    var inputValue: Encodable? { get }
    var isChanged: Bool { get }
    func encode(to encoder: Encoder) throws
    func decode(from decoder: Decoder) throws
}

public protocol ColumnRepresentable {
    associatedtype Value: Codable
    var column: Column<Value> { get }
}

#if swift(>=5.4)
private protocol AnyOptional {
    static var nilValue: Self { get }
}

extension Optional: AnyOptional {
    static var nilValue: Optional<Wrapped> { .none }
}
#endif

@propertyWrapper
public final class Column<Value>: AnyColumn, ColumnRepresentable, ColumnRootNameable, Encodable where Value: Codable {
    public let name: String
    public let type: SwifQL.`Type`
    public let `default`: ColumnDefault?
    public let constraints: [Constraint]
    
    var outputValue: Value?
    public internal(set) var inputValue: Encodable?
    public var isChanged: Bool = false
    
    public var column: Column<Value> { self }
    public var columnName: String { column.name }
    
    public var projectedValue: Column<Value> { self }
    
    public var wrappedValue: Value {
        get {
            if let value = self.inputValue {
                return value as! Value
            } else if let value = self.outputValue {
                return value
            } else {
                #if swift(>=5.4)
                if let type = Value.self as? AnyOptional.Type {
                    return type.nilValue as! Value
                }
                #endif
                fatalError("Cannot access \"\(columnName)\" field before it is initialized or fetched")
            }
        }
        set {
            self.inputValue = newValue
            self.isChanged = true
        }
    }
    
    /// Type will be selected automatically based on Swift type
    public init(_ name: String, default: ColumnDefault? = nil, constraints: Constraint...) {
        let autoType = Self.autoType(constraints)
        self.name = name
        self.type = autoType.type
        self.default = `default`
        var constraints = constraints
        if !autoType.isOptional, !constraints.contains(where: { $0.isNotNull || $0.isPrimaryKey }) {
            constraints.append(.notNull)
        }
        self.constraints = constraints
    }
    
    public init(name: String, type: SwifQL.`Type`, default: ColumnDefault? = nil, constraints: Constraint...) {
        self.name = name
        self.type = type
        self.default = `default`
        self.constraints = constraints
    }
    
    /// See `Codable`
    
    public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        try container.encode(self.wrappedValue)
    }

    public func decode(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let valueType = Value.self as? _Optional.Type {
            if container.decodeNil() {
                self.wrappedValue = (valueType._none as! Value)
            } else {
                self.wrappedValue = try container.decode(Value.self)
            }
        } else {
            self.wrappedValue = try container.decode(Value.self)
        }
        self.isChanged = false
    }
}

public struct ColumnDefault {
    let query: SwifQLable
    
    init (_ query: SwifQLable) {
        self.query = query
    }
    
    public static func `default`(_ v: Any) -> ColumnDefault {
        var parts: [SwifQLPart] = []
        parts.append(o: .default)
        parts.append(o: .space)
        parts.append(safe: v)
        return .init(SwifQLableParts(parts: parts))
    }
    
    public static func `default`(_ expression: SwifQLable) -> ColumnDefault {
        var parts: [SwifQLPart] = []
        parts.append(o: .default)
        parts.append(o: .space)
        parts.append(contentsOf: expression.parts)
        return .init(SwifQLableParts(parts: parts))
    }
    
    public static func `default`(sequence name: String) -> ColumnDefault {
        .init(SwifQLableParts(parts: Op.custom(name)))
    }
}

public protocol ColumnRoot {
    init ()
    
    static func key<C>(for column: KeyPath<Self, C>) -> String where C: ColumnRootNameable
}

extension ColumnRoot {
    public static func key<Column>(for column: KeyPath<Self, Column>) -> String where Column: ColumnRootNameable {
        Self.init()[keyPath: column].columnName
    }
}

public protocol ColumnRootNameable {
    var columnName: String { get }
}


================================================
FILE: Sources/SwifQL/Constraint.swift
================================================
//
//  Constraint.swift
//  SwifQL
//
//  Created by Mihael Isaev on 19.04.2020.
//

import Foundation

public struct Constraint {
    let query: SwifQLable
    
    init (_ query: SwifQLable) {
        self.query = query
    }
    
    var isPrimaryKey = false
    var isNotNull = false
    
    public static var primaryKey: Constraint {
        var constraint = Constraint(SwifQL.primary.key)
        constraint.isPrimaryKey = true
        return constraint
    }
    
    public static var unique: Constraint {
        .init(SwifQL.unique)
    }
    
    public static var notNull: Constraint {
        var constraint = Constraint(SwifQL.not.null)
        constraint.isNotNull = true
        return constraint
    }
    
    public static func check(name: String? = nil, _ expression: SwifQLable) -> Constraint {
        var query = SwifQL
        if let name = name {
            query = query.constraint[any: Path.Column(name)]
        }
        return .init(query.check.values(expression))
    }
    
    public static func references<T: Table>(_ table: T.Type, onDelete: ReferentialAction? = nil, onUpdate: ReferentialAction? = nil) -> Constraint {
        var schemaName: String?
        if let schemable = table as? Schemable.Type {
            schemaName = schemable.schemaName
        }
        return references(schemaName, table.tableName, onDelete: onDelete, onUpdate: onUpdate)
    }
    
    public static func references(_ schema: String? = nil, _ table: String, onDelete: ReferentialAction? = nil, onUpdate: ReferentialAction? = nil) -> Constraint {
        var query = SwifQL.references[any: Path.SchemaWithTable(schema: schema, table: table)]
        if let action = onDelete {
            query = query.on.delete[any: action]
        }
        if let action = onUpdate {
            query = query.on.update[any: action]
        }
        return .init(query)
    }
}


================================================
FILE: Sources/SwifQL/Dialect/Dialect+MySQL.swift
================================================
//
//  Dialect+MySQL.swift
//
//
//  Created by Mihael Isaev on 25.01.2020.
//

import Foundation

class MySQLDialect: SQLDialect {
    override var id: String? { "mysql" }
    
    override func keyPath(_ keyPath: SwifQLPartKeyPath) -> String {
        var result = ""
        if let schema = keyPath.schema {
            result.append(schemaName(schema))
        }
        if let table = keyPath.table {
            if result.count > 0 {
                result.append(".")
            }
            result.append(tableName(table))
        }
        if let lastPath = keyPath.paths.last {
            if result.count > 0 {
                result.append(".")
            }
            result.append(lastPath)
        }
        return result
    }
    
    override func date(_ value: Date) -> String {
        Fn.from_unixtime(value.timeIntervalSince1970).prepare(self).plain
    }
    
    override func bindKey(_ i: Int) -> String { "?" }
    
    override var arrayStart: String { "'" }
    
    override var arrayEnd: String { "'" }
}


================================================
FILE: Sources/SwifQL/Dialect/Dialect+Postgres.swift
================================================
//
//  Dialect+Postgres.swift
//
//
//  Created by Mihael Isaev on 25.01.2020.
//

import Foundation

class PostgreSQLDialect: SQLDialect {
    override var id: String? { "psql" }
    
    override func schemaName(_ value: String) -> String { value.doubleQuotted }
    
    override func tableName(_ value: String) -> String { value.doubleQuotted }
    
    override func alias(_ value: String) -> String { value.doubleQuotted }
    
    override func column(_ value: String) -> String { value.doubleQuotted }
    
    override func jsonField(_ value: String) -> String { value.singleQuotted }
    
    override func keyPath(_ keyPath: SwifQLPartKeyPath) -> String {
        var result = ""
        if let schema = keyPath.schema {
            result.append(schemaName(schema))
        }
        if let table = keyPath.table {
            if result.count > 0 {
                result.append(".")
            }
            result.append(tableName(table))
        }
        for (i, v) in keyPath.paths.enumerated() {
            if i == 0 {
                if result.count > 0 {
                    result.append(".")
                }
                result.append(column(v))
            } else {
                if keyPath.asText, i == keyPath.paths.count - 1 {
                    result.append("->>")
                } else {
                    result.append("->")
                }
                result.append(jsonField(v))
            }
        }
        return result
    }
    
    private lazy var _dateFormatter = PostgresDateFormatter()
    
    override func date(_ value: Date) -> String {
        let date = _dateFormatter.string(from: value) => .timestamptz
        let result = |date|
        return result.prepare(self).plain
    }
    
    // returns $1 $2 $3 binding keys for PostgreSQL
    override func bindKey(_ i: Int) -> String { "$\(i)" }
    
    override var arrayStart: String { Operator.array._value + Operator.openSquareBracket._value }
    override var emptyArrayStart: String { "'" + Operator.openBrace._value }
    
    override var arrayEnd: String { Operator.closeSquareBracket._value }
    override var emptyArrayEnd: String { Operator.closeBrace._value + "'" }
}

class PostgresDateFormatter: DateFormatter {
    override init() {
        super.init()
        calendar = Calendar(identifier: .iso8601)
        locale = Locale(identifier: "en_US_POSIX")
        timeZone = TimeZone.current
        dateFormat = "yyyy-MM-dd HH:mm:ssZZZZZ"
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


================================================
FILE: Sources/SwifQL/Dialect/Dialect.swift
================================================
//
//  Dialect.swift
//
//
//  Created by Mihael Isaev on 25.01.2020.
//

import Foundation

open class SQLDialect {
    open var id: String? { nil }
    
    public static var mysql: SQLDialect {
        MySQLDialect()
    }
    
    public static var psql: SQLDialect {
        PostgreSQLDialect()
    }
    
    public static var all: [SQLDialect] {
        [.psql, .mysql]
    }
    
    /// Good choice only for super short and universal queries like `BEGIN;`, `ROLLBACK;`, `COMMIT;`
    public static var any: SQLDialect {
        .init()
    }
    
    init () {}
    
    open func boolValue(_ value: Bool) -> String {
        value ? "TRUE" : "FALSE"
    }
    
    open var arrayStart: String { "" }
    open var emptyArrayStart: String { arrayStart }
    
    open var arraySeparator: String { Operator.comma._value }
    
    open var arrayEnd: String { "" }
    open var emptyArrayEnd: String { arrayEnd }
    
    open func schemaName(_ value: String) -> String { value }
    
    open func tableName(_ value: String) -> String { value }
    
    open func alias(_ value: String) -> String { value }
    
    open func column(_ value: String) -> String { value }
    
    open func stringValue(_ value: String) -> String { value.singleQuotted }
    
    open func uuidValue(_ value: UUID) -> String { stringValue(value.uuidString) }
    
    open func jsonField(_ value: String) -> String { value }
    
    open func tableName(_ tableName: String, andAlias alias: String) -> String {
        self.tableName(tableName) + " AS " + self.alias(alias)
    }
    
    open func keyPath(_ keyPath: SwifQLPartKeyPath) -> String {
        "<key_path_should_be_here: override dialect function to fix>"
    }
    
    open func date(_ value: Date) -> String {
        "<date_should_be_here: override dialect function to fix>"
    }
    
    open var null: String { "NULL" }
    
    open func safeValue(_ value: Any?) -> String {
        guard let value = value else { return null }
        switch value {
        case let v as String: return stringValue(v)
        case let v as UUID: return uuidValue(v)
        case let v as Bool: return boolValue(v)
        case let v as UInt: return String(describing: v)
        case let v as UInt8: return String(describing: v)
        case let v as UInt16: return String(describing: v)
        case let v as UInt32: return String(describing: v)
        case let v as UInt64: return String(describing: v)
        case let v as Int: return String(describing: v)
        case let v as Int8: return String(describing: v)
        case let v as Int16: return String(describing: v)
        case let v as Int32: return String(describing: v)
        case let v as Int64: return String(describing: v)
        case let v as Float: return String(describing: v)
        case let v as Double: return String(describing: v)
        case let v as Decimal: return String(describing: v)
        default: return stringValue(String(describing: "<unsafe value>")) // TODO:
        }
    }
    
    // MARK: - Binding (for formatter)
    
    open var bindSymbol: String { "§§§" }
    
    open func bindKey(_ i: Int) -> String { "?" }
}

extension SQLDialect: Equatable {
    public static func == (lhs: SQLDialect, rhs: SQLDialect) -> Bool {
        lhs.id == rhs.id
    }
}


================================================
FILE: Sources/SwifQL/Enum.swift
================================================
//
//  Enum.swift
//  SwifQL
//
//  Created by Mihael Isaev on 27.01.2020.
//

import Foundation

public protocol AnySwifQLEnum: Codable, SwifQLable {
    static var name: String { get }
    var anyRawValue: Any { get }
}

protocol AnySwifQLEnumArray {
    var items: [AnySwifQLEnum] { get }
}

extension Array: AnySwifQLEnumArray where Element: AnySwifQLEnum {
    var items: [AnySwifQLEnum] { self }
}

public protocol SwifQLEnum: AnySwifQLEnum, RawRepresentable, CaseIterable {
    static var name: String { get }
}

extension SwifQLEnum {
    public static var name: String { String(describing: Self.self).lowercased() }
    public var anyRawValue: Any { rawValue }
}

/// See `SwifQLable`
extension SwifQLEnum {
    public var parts: [SwifQLPart] { [SwifQLPartSafeValue(rawValue)] }
}

/// Allows to compare enum with enum column
///
/// Usage:
/// 
/// ```swift
/// \User.$status == UserStatus.banned
/// ```
public func == <A, B>(lhs: KeyPath<A, B>, rhs: B.Value.RawValue) -> SwifQLable
    where A: Table, B: ColumnRepresentable, B: ColumnRootNameable, B.Value: SwifQLEnum {
    SwifQLPredicate(operator: .equal, lhs: lhs, rhs: SwifQLableParts(parts: SwifQLPartSafeValue(rhs)))
}


================================================
FILE: Sources/SwifQL/Extensions/Array+SwifQLable.swift
================================================
//
//  Array+SwifQLable.swift
//
//
//  Created by Mihael Isaev on 26.01.2020.
//

import Foundation

extension Array: SwifQLable where Element: SwifQLable {
    public var parts: [SwifQLPart] {
        if let _ = Element.self as? AnySwifQLEnum.Type {
            let values = compactMap {
                ($0 as? AnySwifQLEnum)?.anyRawValue as? String
            }.joined(separator: ",")
            return [SwifQLPartSafeValue("{\(values)}")]
        }
        if let s = self as? SwifQLCodable {
            return [SwifQLPartUnsafeValue(s)]
        } else {
            return separator(.comma).parts
        }
    }
}

extension Array where Element: SwifQLable {
    public func separator(_ separator: SwifQLableArraySeparator) -> SwifQLable {
        var parts: [SwifQLPart] = []
        for (i, v) in enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        return SwifQLableParts(parts: parts)
    }
}

extension Array: SwifQLPart where Element: SwifQLable {}

extension Array: SwifQLPartArray where Element: SwifQLable {
    public var elements: [SwifQLable] { self }
}


================================================
FILE: Sources/SwifQL/Extensions/Column+AutoType.swift
================================================
//
//  Column+AutoType.swift
//  SwifQL
//
//  Created by Mihael Isaev on 27.01.2020.
//

import Foundation

extension Column {
    struct AutoType {
        let type: SwifQL.`Type`
        let isOptional: Bool
        
        init (_ type: SwifQL.`Type`, _ isOptional: Bool) {
            self.type = type
            self.isOptional = isOptional
        }
    }
    
    static func autoType(_ constraints: [Constraint]) -> AutoType {
        var isOptional = false
        switch Value.self {
        case is Optional<String>.Type: isOptional = true; fallthrough
        case is String.Type: return .init(.text, isOptional)
        
        case is Optional<[String]>.Type: isOptional = true; fallthrough
        case is [String].Type: return .init(.textArray, isOptional)
        
        case is Optional<UUID>.Type: isOptional = true; fallthrough
        case is UUID.Type: return .init(.uuid, isOptional)
        
        case is Optional<[UUID]>.Type: isOptional = true; fallthrough
        case is [UUID].Type: return .init(.uuidArray, isOptional)
        
        case is Optional<Double>.Type: isOptional = true; fallthrough
        case is Double.Type: return .init(.decimal, isOptional)
        
        case is Optional<[Double]>.Type: isOptional = true; fallthrough
        case is [Double].Type: return .init(.decimalArray, isOptional)
        
        case is Optional<Float>.Type: isOptional = true; fallthrough
        case is Float.Type: return .init(.float4, isOptional)
        
        case is Optional<[Float]>.Type: isOptional = true; fallthrough
        case is [Float].Type: return .init(.float4Array, isOptional)
        
        case is Optional<UInt>.Type: isOptional = true; fallthrough
        case is UInt.Type: fallthrough
        
        case is Optional<UInt8>.Type: isOptional = true; fallthrough
        case is UInt8.Type: fallthrough
        
        case is Optional<UInt16>.Type: isOptional = true; fallthrough
        case is UInt16.Type: fallthrough
        
        case is Optional<UInt32>.Type: isOptional = true; fallthrough
        case is UInt32.Type: fallthrough
        
        case is Optional<UInt64>.Type: isOptional = true; fallthrough
        case is UInt64.Type: return .init(.int, isOptional)
        
        case is Optional<[UInt]>.Type: isOptional = true; fallthrough
        case is [UInt].Type: fallthrough
        
        case is Optional<[UInt8]>.Type: isOptional = true; fallthrough
        case is [UInt8].Type: fallthrough
        
        case is Optional<[UInt16]>.Type: isOptional = true; fallthrough
        case is [UInt16].Type: fallthrough
        
        case is Optional<[UInt32]>.Type: isOptional = true; fallthrough
        case is [UInt32].Type: fallthrough
        
        case is Optional<[UInt64]>.Type: isOptional = true; fallthrough
        case is [UInt64].Type: return .init(.intArray, isOptional)
        
        case is Optional<Int8>.Type: isOptional = true; fallthrough
        case is Int8.Type: fallthrough
        
        case is Optional<Int16>.Type: isOptional = true; fallthrough
        case is Int16.Type: fallthrough
        
        case is Optional<Int32>.Type: isOptional = true; fallthrough
        case is Int32.Type: fallthrough
        
        case is Optional<Int>.Type: isOptional = true; fallthrough
        case is Int.Type:
            if constraints.contains(where: { $0.isPrimaryKey }) {
                return .init(.serial, isOptional)
            } else {
                return .init(.int, isOptional)
            }
        
        case is Optional<Int64>.Type: isOptional = true; fallthrough
        case is Int64.Type:
            if constraints.contains(where: { $0.isPrimaryKey }) {
                return .init(.bigserial, isOptional)
            } else {
                return .init(.bigint, isOptional)
            }
        
        case is Optional<[Int8]>.Type: isOptional = true; fallthrough
        case is [Int8].Type: fallthrough
        
        case is Optional<[Int16]>.Type: isOptional = true; fallthrough
        case is [Int16].Type: fallthrough
        
        case is Optional<[Int32]>.Type: isOptional = true; fallthrough
        case is [Int32].Type: fallthrough
        
        case is Optional<[Int]>.Type: isOptional = true; fallthrough
        case is [Int].Type: return .init(.intArray, isOptional)
        
        case is Optional<[Int64]>.Type: isOptional = true; fallthrough
        case is [Int64].Type: return .init(.bigintArray, isOptional)
        
        case is Optional<Date>.Type: isOptional = true; fallthrough
        case is Date.Type: return .init(.timestamptz, isOptional)
        
        case is Optional<[Date]>.Type: isOptional = true; fallthrough
        case is [Date].Type: return .init(.timestamptzArray, isOptional)
        
        case is Optional<Data>.Type: isOptional = true; fallthrough
        case is Data.Type: return .init(.bytea, isOptional)
        
        case is Optional<[Data]>.Type: isOptional = true; fallthrough
        case is [Data].Type: return .init(.byteaArray, isOptional)
            
        case is AnyOptionalEnum.Type:
            guard let t = Value.self as? AnyOptionalEnum.Type else { fallthrough }
            return .init(.custom(t.name), true)
        case is AnySwifQLEnum.Type:
            guard let t = Value.self as? AnySwifQLEnum.Type else { fallthrough }
            return .init(.custom(t.name), false)
        
        case is Optional<[Encodable]>.Type: isOptional = true; fallthrough
        case is [Encodable].Type: return .init(.jsonbArray, isOptional)
        
        case is ClosedRange<Date>.Type: return .init(.daterange, isOptional)
        case is Range<Date>.Type: return .init(.daterange, isOptional)
        
        default: return .init(.text, true)
        }
    }
}
fileprivate protocol AnyOptionalEnum {
    static var name: String { get }
}
extension Optional: AnyOptionalEnum where Wrapped: AnySwifQLEnum {
    fileprivate static var name: String { return Wrapped.name }
}
extension Optional {
    fileprivate static var trololo: Wrapped.Type { return Wrapped.self }
}


================================================
FILE: Sources/SwifQL/Extensions/Decodable+Table.swift
================================================
//
//  Decodable+Table.swift
//  
//
//  Created by Mihael Isaev on 26.01.2020.
//

import Foundation

extension Decodable {
    public static var table: SwifQLable {
        let tableName: String
        if let model = Self.self as? AnyTable.Type {
            tableName = model.tableName
        } else {
            tableName = String(describing: Self.self)
        }
        if let schema = Self.self as? Schemable.Type {
            return Path.SchemaWithTable(schema: schema.schemaName, table: tableName)
        } else {
            return Path.Table(tableName)
        }
    }
}


================================================
FILE: Sources/SwifQL/Extensions/StringExtensions.swift
================================================
//
//  StringExtensions.swift
//  App
//
//  Created by Mihael Isaev on 06.06.2018.
//

import Foundation

extension String {
    public var singleQuotted: String {
        "'\(self)'"
    }
    
    public var doubleQuotted: String {
        "\"\(self)\""
    }
    
    public var roundBracketted: String {
        "(\(self))"
    }
    
    public static func singleQuotted(_ v: Any) -> String {
        "\(v)".singleQuotted
    }
    
    public static func doubleQuotted(_ v: Any) -> String {
        "\(v)".doubleQuotted
    }
    
    public static func roundBracketted(_ v: Any) -> String {
        "\(v)".roundBracketted
    }
    
    public func `as`(_ v: String) -> String {
        self + " as " + v
    }
}


================================================
FILE: Sources/SwifQL/ExtractFieldValue.swift
================================================
//
//  ExtractFieldValue.swift
//  SwifQL
//
//  Created by Mihael Isaev on 29/10/2019.
//

public struct ExtractFieldValue {
    public let value: String
    
    /// Postgres specific
    /// for TIMESTAMP: The century
    /// for Interval: The number of centuries
    public static var century: ExtractFieldValue { .init(value: "CENTURY") }
    
    /// Universal
    /// for TIMESTAMP: The day of the month (1-31)
    /// for Interval: The number of days
    public static var day: ExtractFieldValue { .init(value: "DAY") }
    
    /// Postgres specific
    /// for TIMESTAMP: The decade that is the year divided by 10
    /// for Interval: Sames as TIMESTAMP
    public static var decade: ExtractFieldValue { .init(value: "DECADE") }
    
    /// Postgres specific
    /// for TIMESTAMP: The day of week Sunday (0) to Saturday (6)
    /// for Interval: N/A
    public static var dow: ExtractFieldValue { .init(value: "DOW") }
    
    /// Postgres specific
    /// for TIMESTAMP: The day of year that ranges from 1 to 366
    /// for Interval: N/A
    public static var doy: ExtractFieldValue { .init(value: "DOY") }
    
    /// Postgres specific
    /// for TIMESTAMP: The number of seconds since 1970-01-01 00:00:00 UTC
    /// for Interval: The total number of seconds in the interval
    public static var epoch: ExtractFieldValue { .init(value: "EPOCH") }
    
    /// Universal
    /// for TIMESTAMP: The hour (0-23)
    /// for Interval: The number of hours
    public static var hour: ExtractFieldValue { .init(value: "HOUR") }
    
    /// Postgres specific
    /// for TIMESTAMP: Day of week based on ISO 8601 Monday (1) to Saturday (7)
    /// for Interval: N/A
    public static var isoDow: ExtractFieldValue { .init(value: "ISODOW") }
    
    /// Postgres specific
    /// for TIMESTAMP: ISO 8601 week number of year
    /// for Interval: N/A
    public static var isoYear: ExtractFieldValue { .init(value: "ISOYEAR") }
    
    /// Postgres specific
    /// for TIMESTAMP: The seconds field, including fractional parts, multiplied by 1000000
    /// for Interval: Sames as TIMESTAMP
    public static var microseconds: ExtractFieldValue { .init(value: "MICROSECONDS") }
    
    /// Postgres specific
    /// for TIMESTAMP: The millennium
    /// for Interval: The number of millennium
    public static var millenium: ExtractFieldValue { .init(value: "MILLENNIUM") }
    
    /// Postgres specific
    /// for TIMESTAMP: The seconds field, including fractional parts, multiplied by 1000
    /// for Interval: Sames as TIMESTAMP
    public static var milliseconds: ExtractFieldValue { .init(value: "MILLISECONDS") }
    
    /// Universal
    /// for TIMESTAMP: The minute (0-59)
    /// for Interval: The number of minutes
    public static var minute: ExtractFieldValue { .init(value: "MINUTE") }
    
    /// Universal
    /// for TIMESTAMP: Month, 1-12
    /// for Interval: The number of months, modulo (0-11)
    public static var month: ExtractFieldValue { .init(value: "MONTH") }
    
    /// Universal
    /// for TIMESTAMP: Quarter of the year
    /// for Interval: The number of quarters
    public static var quarter: ExtractFieldValue { .init(value: "QUARTER") }
    
    /// Universal
    /// for TIMESTAMP: The second
    /// for Interval: The number of seconds
    public static var second: ExtractFieldValue { .init(value: "SECOND") }
    
    /// Postgres specific
    /// for TIMESTAMP: The timezone offset from UTC, measured in seconds
    /// for Interval: N/A
    public static var timeZone: ExtractFieldValue { .init(value: "TIMEZONE") }
    
    /// Postgres specific
    /// for TIMESTAMP: The hour component of the time zone offset
    /// for Interval: N/A
    public static var timeZoneHour: ExtractFieldValue { .init(value: "TIMEZONE_HOUR") }
    
    /// Postgres specific
    /// for TIMESTAMP: The minute component of the time zone offset
    /// for Interval: N/A
    public static var timeZoneMinute: ExtractFieldValue { .init(value: "TIMEZONE_MINUTE") }
    
    /// Universal
    /// for TIMESTAMP: The number of the ISO 8601 week-numbering week of the year
    /// for Interval: N/A
    public static var week: ExtractFieldValue { .init(value: "WEEK") }
    
    /// Universal
    /// for TIMESTAMP: The year
    /// for Interval: Sames as TIMESTAMP
    public static var year: ExtractFieldValue { .init(value: "YEAR") }
    
    /// MySQL specific
    public static var microsecond: ExtractFieldValue { .init(value: "MICROSECOND") }
    
    /// MySQL specific
    public static var secondMicrosecond: ExtractFieldValue { .init(value: "SECOND_MICROSECOND") }
    
    /// MySQL specific
    public static var minuteMicrosecond: ExtractFieldValue { .init(value: "MINUTE_MICROSECOND") }
    
    /// MySQL specific
    public static var minuteSecond: ExtractFieldValue { .init(value: "MINUTE_SECOND") }
    
    /// MySQL specific
    public static var hourMicrosecond: ExtractFieldValue { .init(value: "HOUR_MICROSECOND") }
    
    /// MySQL specific
    public static var hourSecond: ExtractFieldValue { .init(value: "HOUR_SECOND") }
    
    /// MySQL specific
    public static var hourMinute: ExtractFieldValue { .init(value: "HOUR_MINUTE") }
    
    /// MySQL specific
    public static var dayMicrosecond: ExtractFieldValue { .init(value: "DAY_MICROSECOND") }
    
    /// MySQL specific
    public static var daySecond: ExtractFieldValue { .init(value: "DAY_SECOND") }
    
    /// MySQL specific
    public static var dayMinute: ExtractFieldValue { .init(value: "DAY_MINUTE") }
    
    /// MySQL specific
    public static var dayHour: ExtractFieldValue { .init(value: "DAY_HOUR") }
    
    /// MySQL specific
    public static var yearMonth: ExtractFieldValue { .init(value: "YEAR_MONTH") }
}


================================================
FILE: Sources/SwifQL/FluentKitFieldable.swift
================================================
public protocol FluentKitFieldable {
    var schema: String { get }
    var key: String { get }
}


================================================
FILE: Sources/SwifQL/FormattedKeyPath.swift
================================================
//
//  FormattedKeyPath.swift
//  SwifQL
//
//  Created by Mihael Isaev on 20/06/2019.
//

import Foundation

/// Formatting keypath
public typealias FKP = FormattedKeyPath

public struct FormattedKeyPath {
    let _table: String
    let _paths: [String]
    
    public init <T: Table>(_ table: T.Type, _ paths: String...) {
        _table = table.tableName
        _paths = paths
    }
    
    public init <T: Table>(_ table: T.Type, _ paths: [String]) {
        _table = table.tableName
        _paths = paths
    }
    
    public init (_ table: String, _ paths: String...) {
        _table = table
        _paths = paths
    }
    
    public init (_ table: String, _ paths: [String]) {
        _table = table
        _paths = paths
    }
}

extension FormattedKeyPath: SwifQLable {
    public var parts: [SwifQLPart] {
        [SwifQLPartKeyPath(table: _table, paths: _paths)]
    }
}

extension FormattedKeyPath: KeyPathLastPath {
    public var lastPath: String { _paths.last ?? "" }
}

extension Table {
    /// Manual key path. Alias to `\User.something`
    public static func manualKeyPath(_ paths: String...) -> FormattedKeyPath {
        manualKeyPath(paths)
    }
    
    /// Manual key path. Alias to `\User.something`
    public static func manualKeyPath(_ paths: [String]) -> FormattedKeyPath {
        FormattedKeyPath(tableName, paths)
    }
    
    /// Manual key path. Alias to `\User.something`
    public static func mkp(_ paths: String...) -> FormattedKeyPath {
        manualKeyPath(paths)
    }
    
    /// Manual key path. Alias to `\User.something`
    public static func mkp(_ paths: [String]) -> FormattedKeyPath {
        manualKeyPath(paths)
    }
}


================================================
FILE: Sources/SwifQL/Formatter.swift
================================================
//
//  Formatter.swift
//  
//
//  Created by Mihael Isaev on 25.01.2020.
//

import Foundation

struct SwifQLFormatter {
    private let dialect: SQLDialect
    private let mode: Mode
    
    init (_ dialect: SQLDialect, mode: Mode) {
        self.dialect = dialect
        self.mode = mode
    }
    
    enum Mode {
        case binded
        case plain
    }
    
    func string(from query: String, with formattedValues: [String]) -> String {
        switch mode {
        case .binded:
            return binded(query)
        case .plain:
            return plain(query: query, with: formattedValues)
        }
    }
    
    private func binded(_ query: String, _ valueRetriever: @escaping (Int) -> String) -> String {
        let rawChars: [Character] = Array(query)
        var finalChars: [Character] = []
        var skipTill = -1
        var b = 1
        for (i, char) in rawChars.enumerated() {
            guard skipTill < i else { continue }
            guard char == dialect.bindSymbol.first else {
                finalChars.append(char)
                continue
            }
            if dialect.bindSymbol.count > 1 {
                guard rawChars.count >= i + dialect.bindSymbol.count else { continue }
                for n in 1...dialect.bindSymbol.count - 1 {
                    guard rawChars[i + n] == Array(dialect.bindSymbol)[n] else { continue }
                }
                skipTill = i + dialect.bindSymbol.count - 1
            }
            finalChars.append(contentsOf: Array(valueRetriever(b)))
            b = b + 1
        }
        return String(finalChars)
    }
    
    private func binded(_ query: String) -> String {
        binded(query) { self.dialect.bindKey($0) }
    }
    
    private func plain(query: String, with formattedValues: [String]) -> String {
        binded(query) { formattedValues[$0 - 1] }
    }
}

extension String {
    fileprivate func split(by length: Int) -> [String] {
        var startIndex = self.startIndex
        var results = [Substring]()

        while startIndex < self.endIndex {
            let endIndex = self.index(startIndex, offsetBy: length, limitedBy: self.endIndex) ?? self.endIndex
            results.append(self[startIndex..<endIndex])
            startIndex = endIndex
        }

        return results.map { String($0) }
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+Array.swift
================================================
//
//  Functions+Array.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static let array_agg: Self = .init("array_agg")
    public static let array_remove: Self = .init("array_remove")
}

extension Fn {
    ///
    public static func array_agg(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.array_agg, body: aggregateExpression.parts)
    }
    
    /// `SELECT array_remove(ARRAY[1,2,3,2], 2);` will return {1,3}
    public static func array_remove(_ queryPart: SwifQLable...) -> SwifQLable {
        array_remove(queryPart)
    }
    
    /// `SELECT array_remove(ARRAY[1,2,3,2], 2);` will return {1,3}
    public static func array_remove(_ queryParts: [SwifQLable]) -> SwifQLable {
        var parts: [SwifQLPart] = []
        for (i, q) in queryParts.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: q.parts)
        }
        return build(.array_remove, body: parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+General.swift
================================================
//
//  Functions+General.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var substr: Self = .init("substr")
    public static var coalesce: Self = .init("coalesce")
    public static var octet_length: Self = .init("octet_length")
    public static var cast: Self = .init("cast")
    public static var ifnull: Self = .init("ifnull")
    public static var isnull: Self = .init("isnull")
    public static var nvl: Self = .init("nvl")
    public static var expression: Self = .init("expression")
}

extension Fn {
    public static func substr(_ queryPart: SwifQLable, _ to: Int) -> SwifQLable {
        var parts: [SwifQLPart] = queryPart.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(safe: to)
        return build(.substr, body: parts)
    }
    
    /// `SELECT COALESCE (NULL, 2 , 1);` will return 2
    public static func coalesce(_ queryPart: SwifQLable...) -> SwifQLable {
        coalesce(queryPart)
    }
    
    /// `SELECT COALESCE (NULL, 2 , 1);` will return 2
    public static func coalesce(_ queryParts: [SwifQLable]) -> SwifQLable {
        var parts: [SwifQLPart] = []
        for (i, q) in queryParts.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
            }
            parts.append(contentsOf: q.parts)
        }
        return build(.coalesce, body: parts)
    }
    
    public static func octet_length(_ string: SwifQLable) -> SwifQLable {
        build(.octet_length, body: string.parts)
    }
    
    public static func cast(_ queryPart: SwifQLable, _ to: Type) -> SwifQLable {
        cast(nil, queryPart, to)
    }
    
    public static func cast(_ from: Type?, _ queryPart: SwifQLable, _ to: Type) -> SwifQLable {
        var parts: [SwifQLPart] = []
        if let from = from?.name {
            parts.append(o: .custom(from))
            parts.append(o: .space)
        }
        parts.append(contentsOf: queryPart.parts)
        parts.append(o: .space)
        parts.append(o: .as)
        parts.append(o: .space)
        parts.append(o: .custom(to.name))
        return build(.cast, body: parts)
    }
    
    public static func ifNull(_ value1: SwifQLable, _ value2: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = value1.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: value2.parts)
        return build(.ifnull, body: parts)
    }
    
    public static func isNull(_ value1: SwifQLable, _ value2: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = value1.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: value2.parts)
        return build(.isnull, body: parts)
    }
    
    public static func nvl(_ value1: SwifQLable, _ value2: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = value1.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: value2.parts)
        return build(.nvl, body: parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+MySQL.swift
================================================
//
//  Functions+MySQL.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var from_unixtime: Self = .init("FROM_UNIXTIME")
    public static var date_format: Self = .init("DATE_FORMAT")
}

extension Fn {
    public static func from_unixtime(_ timeinterval: SwifQLable, _ format: String? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = timeinterval.parts
        if let format = format {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(o: .custom(format.singleQuotted))
        }
        return build(.from_unixtime, body: parts)
    }

    /// Formats the date value according to the format string.
    /// # Example
    /// ```swift
    /// Fn.date_format(\User.createdAt, "%y-%m")
    /// ```
    /// # Result
    /// ```
    /// date_format(User.createdAt, '%y-%m')
    /// ```
    /// [Learn more →](https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format)
    /// [Learn more →](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format)
    public static func date_format(_ datetime: SwifQLable, _ format: String) -> SwifQLable {
        var parts: [SwifQLPart] = datetime.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(o: .custom(format.singleQuotted))
        return build(.date_format, body: parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+Numeric.swift
================================================
//
//  Functions+Numeric.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var abs: Self = .init("abs")
    public static var avg: Self = .init("avg")
    public static var ceil: Self = .init("ceil")
    public static var ceiling: Self = .init("ceiling")
    public static var count: Self = .init("count")
    public static var div: Self = .init("div")
    public static var exp: Self = .init("exp")
    public static var floor: Self = .init("floor")
    public static var max: Self = .init("max")
    public static var min: Self = .init("min")
    public static var mod: Self = .init("mod")
    public static var power: Self = .init("power")
    public static var random: Self = .init("random")
    public static var round: Self = .init("round")
    public static var setseed: Self = .init("setseed")
    public static var sign: Self = .init("sign")
    public static var sqrt: Self = .init("sqrt")
    public static var sum: Self = .init("sum")
}

extension Fn {
    /// Returns the absolute value of a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/abs.php)
    public static func abs(_ number: SwifQLable) -> SwifQLable {
        build(.abs, body: number.parts)
    }
    
    /// Returns the average value of an expression
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/avg.php)
    public static func avg(_ quantity: SwifQLable) -> SwifQLable {
        build(.avg, body: quantity.parts)
    }
    
    /// Returns the smallest integer value that is greater than or equal to a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/ceil.php)
    public static func ceil(_ number: SwifQLable) -> SwifQLable {
        build(.ceil, body: number.parts)
    }
    
    /// Returns the smallest integer value that is greater than or equal to a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/ceiling.php)
    public static func ceiling(_ number: SwifQLable) -> SwifQLable {
        build(.ceiling, body: number.parts)
    }
    
    /// Returns the count of an expression
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/count.php)
    public static func count(_ expression: SwifQLable) -> SwifQLable {
        build(.count, body: expression.parts)
    }
    
    /// Used for integer division where n is divided by m and an integer value is returned
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/div.php)
    public static func div(_ n: SwifQLable, _ m: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = n.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: m.parts)
        return build(.div, body: parts)
    }
    
    /// Used for integer division where n is divided by m and an integer value is returned
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/exp.php)
    public static func exp(_ n: SwifQLable, _ m: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = n.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: m.parts)
        return build(.exp, body: parts)
    }
    
    /// Returns the largest integer value that is equal to or less than a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/floor.php)
    public static func floor(_ number: SwifQLable) -> SwifQLable {
        build(.floor, body: number.parts)
    }
    
    /// Returns the maximum value of an expression
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/max.php)
    public static func max(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.max, body: aggregateExpression.parts)
    }
    
    /// Returns the minimum value of an expression
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/min.php)
    public static func min(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.min, body: aggregateExpression.parts)
    }
    
    /// Returns the remainder of n divided by m
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/mod.php)
    public static func mod(_ n: SwifQLable, _ m: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = n.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: m.parts)
        return build(.mod, body: parts)
    }
    
    /// Returns m raised to the nth power
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/power.php)
    public static func power(_ n: SwifQLable, _ m: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = n.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: m.parts)
        return build(.power, body: parts)
    }
    
    /// Random function can be used to return a random number or a random number within a range
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/random.php)
    public static func random() -> SwifQLable {
        build(.random, body: [])
    }
    
    /// Returns a number rounded to a certain number of decimal places
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/round.php)
    public static func round(_ number: SwifQLable, _ decimalPlaces: Int? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = number.parts
        if let decimalPlaces = decimalPlaces {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(safe: decimalPlaces)
        }
        return build(.round, body: parts)
    }
    
    /// Can be used to set a seed for the next time that you call the random function.
    /// If you do not call setseed, PostgreSQL will use its own seed value.
    /// This may or may not be truly random.
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/setseed.php)
    public static func setseed(_ number: SwifQLable) -> SwifQLable {
        build(.setseed, body: number.parts)
    }
    
    /// Returns a value indicating the sign of a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/sign.php)
    public static func sign(_ number: SwifQLable) -> SwifQLable {
        build(.sign, body: number.parts)
    }
    
    /// Returns the square root of a number
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/sqrt.php)
    public static func sqrt(_ number: SwifQLable) -> SwifQLable {
        build(.sqrt, body: number.parts)
    }
    
    /// Returns the summed value of an expression
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/sum.php)
    public static func sum(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.sum, body: aggregateExpression.parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+PostgresBool.swift
================================================
//
//  Functions+PostgresBool.swift
//  SwifQL
//
//  Created by Ethan Lozano on 06.12.20.
//

import Foundation

extension Fn.Name {
    public static let bool_and: Self = .init("bool_and")
    public static let bool_or: Self = .init("bool_or")
}

extension Fn {

    public static func bool_and(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.bool_and, body: aggregateExpression.parts)
    }

    public static func bool_or(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.bool_or, body: aggregateExpression.parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+PostgresJSON.swift
================================================
//
//  Functions+PostgresJSON.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var json_agg: Self = .init("json_agg")
    public static var to_json: Self = .init("to_json")
    public static var array_to_json: Self = .init("array_to_json")
    public static var row_to_json: Self = .init("row_to_json")
    public static var json_build_array: Self = .init("json_build_array")
    public static var json_build_object: Self = .init("json_build_object")
    public static var json_object: Self = .init("json_object")
    public static var json_array_length: Self = .init("json_array_length")
    public static var json_each: Self = .init("json_each")
    public static var json_each_text: Self = .init("json_each_text")
    public static var json_extract_path: Self = .init("json_extract_path")
    public static var json_extract_path_text: Self = .init("json_extract_path_text")
    public static var json_object_keys: Self = .init("json_object_keys")
    public static var json_populate_record: Self = .init("json_populate_record")
    public static var json_populate_recordset: Self = .init("json_populate_recordset")
    public static var json_array_elements: Self = .init("json_array_elements")
    public static var json_array_elements_text: Self = .init("json_array_elements_text")
    public static var json_typeof: Self = .init("json_typeof")
    public static var json_to_record: Self = .init("json_to_record")
    public static var json_to_recordset: Self = .init("json_to_recordset")
    public static var json_strip_nulls: Self = .init("json_strip_nulls")
}

extension Fn {
    ///
    public static func json_agg(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_agg, body: aggregateExpression.parts)
    }
    
    /// Returns the value as json.
    /// Arrays and composites are converted (recursively) to arrays and objects;
    /// otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion;
    /// otherwise, a scalar value is produced.
    /// For any scalar type other than a number, a Boolean, or a null value,
    /// the text representation will be used, in such a fashion that it is a valid json or jsonb value.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func to_json(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.to_json, body: aggregateExpression.parts)
    }
    
    /// Returns the array as a JSON array.
    /// A PostgreSQL multidimensional array becomes a JSON array of arrays.
    /// Line feeds will be added between dimension-1 elements if pretty_bool is true
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func array_to_json(_ anyarray: SwifQLable, pretty: Bool? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = anyarray.parts
        if let pretty = pretty {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(safe: pretty)
        }
        return build(.array_to_json, body: parts)
    }
    
    /// Returns the row as a JSON object.
    /// Line feeds will be added between level-1 elements if pretty_bool is true
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func row_to_json(_ record: SwifQLable, pretty: Bool? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = record.parts
        if let pretty = pretty {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(safe: pretty)
        }
        return build(.row_to_json, body: parts)
    }
    
    /// Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_build_array(_ items: SwifQLable...) -> SwifQLable {
        json_build_array(items)
    }
    
    /// Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_build_array(_ items: [SwifQLable]) -> SwifQLable {
        var parts: [SwifQLPart] = []
        for (i, v) in items.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        return build(.json_build_array, body: parts)
    }
    
    /// Builds a JSON object out of a variadic argument list.
    /// By convention, the argument list consists of alternating keys and values
    /// # Example
    /// ```swift
    /// Fn.json_build_object("foo", 1, "bar", 2)
    /// ```
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_build_object(_ items: SwifQLable...) -> SwifQLable {
        json_build_object(items)
    }
    
    /// Builds a JSON object out of a variadic argument list.
    /// By convention, the argument list consists of alternating keys and values
    /// # Example
    /// ```swift
    /// Fn.json_build_object("foo", 1, "bar", 2)
    /// ```
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_build_object(_ items: [SwifQLable]) -> SwifQLable {
        var parts: [SwifQLPart] = []
        for (i, v) in items.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        return build(.json_build_object, body: parts)
    }
    
    /// Builds a JSON object out of a text array.
    /// The array must have either exactly one dimension with an even number of members,
    /// in which case they are taken as alternating key/value pairs,
    /// or two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_object(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_object, body: aggregateExpression.parts)
    }
    
    /// This form of json_object takes keys and values pairwise from two separate arrays.
    /// In all other respects it is identical to the one-argument form.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_object(keys: SwifQLable, values: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = keys.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: values.parts)
        return build(.json_object, body: parts)
    }
    
    /// Returns the number of elements in the outermost JSON array
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_array_length(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_array_length, body: aggregateExpression.parts)
    }
    
    /// Expands the outermost JSON object into a set of key/value pairs
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_each(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_each, body: aggregateExpression.parts)
    }
    
    /// Expands the outermost JSON object into a set of key/value pairs. The returned values will be of type text
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_each_text(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_each_text, body: aggregateExpression.parts)
    }
    
    /// Returns JSON value pointed to by path_elems (equivalent to #> operator)
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_extract_path(_ from_json: SwifQLable, path_elems: [String]) -> SwifQLable {
        var parts: [SwifQLPart] = from_json.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        for (i, v) in path_elems.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        
        return build(.json_extract_path, body: parts)
    }
    
    public static func json_extract_path(_ from_json: SwifQLable, path_elems: String...) -> SwifQLable {
        json_extract_path(from_json, path_elems: path_elems)
    }
    
    /// Returns JSON value pointed to by path_elems as text (equivalent to #>> operator)
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_extract_path_text(_ from_json: SwifQLable, path_elems: [String]) -> SwifQLable {
        var parts: [SwifQLPart] = from_json.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        for (i, v) in path_elems.enumerated() {
            if i > 0 {
                parts.append(o: .comma)
                parts.append(o: .space)
            }
            parts.append(contentsOf: v.parts)
        }
        
        return build(.json_extract_path_text, body: parts)
    }
    
    public static func json_extract_path_text(_ from_json: SwifQLable, path_elems: String...) -> SwifQLable {
        json_extract_path_text(from_json, path_elems: path_elems)
    }
    
    /// Returns set of keys in the outermost JSON object.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_object_keys(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_object_keys, body: aggregateExpression.parts)
    }
    
    /// Expands the object in from_json to a row whose columns match the record type defined by base (see note below).
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_populate_record(base: SwifQLable, from_json: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = base.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: from_json.parts)
        return build(.json_populate_record, body: parts)
    }
    
    /// Expands the outermost array of objects in from_json to a set of rows whose columns match the record type defined by base (see note below).
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_populate_recordset(base: SwifQLable, from_json: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = base.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: from_json.parts)
        return build(.json_populate_recordset, body: parts)
    }
    
    /// Expands a JSON array to a set of JSON values.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_array_elements(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_array_elements, body: aggregateExpression.parts)
    }
    
    /// Expands a JSON array to a set of text values.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_array_elements_text(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_array_elements_text, body: aggregateExpression.parts)
    }
    
    /// Returns the type of the outermost JSON value as a text string. Possible types are object, array, string, number, boolean, and null.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_typeof(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_typeof, body: aggregateExpression.parts)
    }
    
    /// Builds an arbitrary record from a JSON object (see note below). As with all functions returning record, the caller must explicitly define the structure of the record with an AS clause.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_to_record(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_to_record, body: aggregateExpression.parts)
    }
    
    /// Builds an arbitrary set of records from a JSON array of objects (see note below). As with all functions returning record, the caller must explicitly define the structure of the record with an AS clause.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_to_recordset(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_to_recordset, body: aggregateExpression.parts)
    }
    
    /// Returns from_json with all object fields that have null values omitted. Other null values are untouched.
    /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    public static func json_strip_nulls(_ aggregateExpression: SwifQLable) -> SwifQLable {
        build(.json_strip_nulls, body: aggregateExpression.parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+PostgresJSONB.swift
================================================
//
//  Functions+PostgresJSONB.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var jsonb_agg: Self = .init("jsonb_agg")
    public static var to_jsonb: Self = .init("to_jsonb")
    public static var jsonb_build_array: Self = .init("jsonb_build_array")
    public static var jsonb_build_object: Self = .init("jsonb_build_object")
    public static var jsonb_object: Self = .init("jsonb_object")
    public static var jsonb_array_length: Self = .init("jsonb_array_length")
    public static var jsonb_each: Self = .init("jsonb_each")
    public static var jsonb_each_text: Self = .init("jsonb_each_text")
    public static var jsonb_extract_path: Self = .init("jsonb_extract_path")
    public static var jsonb_extract_path_text: Self = .init("jsonb_extract_path_text")
    public static var jsonb_object_keys: Self = .init("jsonb_object_keys")
    public static var jsonb_populate_record: Self = .init("jsonb_populate_record")
    public static var jsonb_populate_recordset: Self = .init("jsonb_populate_recordset")
    public static var jsonb_array_elements: Self = .init("jsonb_array_elements")
    public static var jsonb_array_elements_text: Self = .init("jsonb_array_elements_text")
    public static var jsonb_typeof: Self = .init("jsonb_typeof")
    public static var jsonb_to_record: Self = .init("jsonb_to_record")
    public static var jsonb_to_recordset: Self = .init("jsonb_to_recordset")
    public static var jsonb_strip_nulls: Self = .init("jsonb_strip_nulls")
    public static var jsonb_set: Self = .init("jsonb_set")
    public static var jsonb_insert: Self = .init("jsonb_insert")
    public static var jsonb_pretty: Self = .init("jsonb_pretty")
}

extension Fn {
    ///
        public static func jsonb_agg(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_agg, body: aggregateExpression.parts)
        }
        
        /// Returns the value as jsonb.
        /// Arrays and composites are converted (recursively) to arrays and objects;
        /// otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion;
        /// otherwise, a scalar value is produced.
        /// For any scalar type other than a number, a Boolean, or a null value,
        /// the text representation will be used, in such a fashion that it is a valid json or jsonb value.
        public static func to_jsonb(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.to_jsonb, body: aggregateExpression.parts)
        }
        
        /// Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_build_array(_ items: SwifQLable...) -> SwifQLable {
            jsonb_build_array(items)
        }
        
        /// Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_build_array(_ items: [SwifQLable]) -> SwifQLable {
            var parts: [SwifQLPart] = []
            for (i, v) in items.enumerated() {
                if i > 0 {
                    parts.append(o: .comma)
                    parts.append(o: .space)
                }
                parts.append(contentsOf: v.parts)
            }
            return build(.jsonb_build_array, body: parts)
        }
        
        /// Builds a JSON object out of a variadic argument list.
        /// By convention, the argument list consists of alternating keys and values
        /// # Example
        /// ```swift
        /// Fn.jsonb_build_object("foo", 1, "bar", 2)
        /// ```
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_build_object(_ items: SwifQLable...) -> SwifQLable {
            jsonb_build_object(items)
        }
        
        /// Builds a JSON object out of a variadic argument list.
        /// By convention, the argument list consists of alternating keys and values
        /// # Example
        /// ```swift
        /// Fn.jsonb_build_object("foo", 1, "bar", 2)
        /// ```
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_build_object(_ items: [SwifQLable]) -> SwifQLable {
            var parts: [SwifQLPart] = []
            for (i, v) in items.enumerated() {
                if i > 0 {
                    parts.append(o: .comma)
                    parts.append(o: .space)
                }
                parts.append(contentsOf: v.parts)
            }
            return build(.jsonb_build_object, body: parts)
        }
        
        /// Builds a JSON object out of a text array.
        /// The array must have either exactly one dimension with an even number of members,
        /// in which case they are taken as alternating key/value pairs,
        /// or two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_object(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_object, body: aggregateExpression.parts)
        }
        
        /// This form of json_object takes keys and values pairwise from two separate arrays.
        /// In all other respects it is identical to the one-argument form.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_object(keys: SwifQLable, values: SwifQLable) -> SwifQLable {
            var parts: [SwifQLPart] = keys.parts
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(contentsOf: values.parts)
            return build(.jsonb_object, body: parts)
        }
        
        /// Returns the number of elements in the outermost JSON array
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_array_length(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_array_length, body: aggregateExpression.parts)
        }
        
        /// Expands the outermost JSON object into a set of key/value pairs
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_each(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_each, body: aggregateExpression.parts)
        }
        
        /// Expands the outermost JSON object into a set of key/value pairs. The returned values will be of type text
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_each_text(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_each_text, body: aggregateExpression.parts)
        }
        
        /// Returns JSON value pointed to by path_elems (equivalent to #> operator)
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_extract_path(_ from_json: SwifQLable, path_elems: [String]) -> SwifQLable {
            var parts: [SwifQLPart] = from_json.parts
            parts.append(o: .comma)
            parts.append(o: .space)
            for (i, v) in path_elems.enumerated() {
                if i > 0 {
                    parts.append(o: .comma)
                    parts.append(o: .space)
                }
                parts.append(contentsOf: v.parts)
            }
            
            return build(.jsonb_extract_path, body: parts)
        }
        
        public static func jsonb_extract_path(_ from_json: SwifQLable, path_elems: String...) -> SwifQLable {
            jsonb_extract_path(from_json, path_elems: path_elems)
        }
        
        /// Returns JSON value pointed to by path_elems as text (equivalent to #>> operator)
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_extract_path_text(_ from_json: SwifQLable, path_elems: [String]) -> SwifQLable {
            var parts: [SwifQLPart] = from_json.parts
            parts.append(o: .comma)
            parts.append(o: .space)
            for (i, v) in path_elems.enumerated() {
                if i > 0 {
                    parts.append(o: .comma)
                    parts.append(o: .space)
                }
                parts.append(contentsOf: v.parts)
            }
            
            return build(.jsonb_extract_path_text, body: parts)
        }
        
        public static func jsonb_extract_path_text(_ from_json: SwifQLable, path_elems: String...) -> SwifQLable {
            jsonb_extract_path_text(from_json, path_elems: path_elems)
        }
        
        /// Returns set of keys in the outermost JSON object.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_object_keys(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_object_keys, body: aggregateExpression.parts)
        }
        
        /// Expands the object in from_json to a row whose columns match the record type defined by base (see note below).
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_populate_record(base: SwifQLable, from_json: SwifQLable) -> SwifQLable {
            var parts: [SwifQLPart] = base.parts
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(contentsOf: from_json.parts)
            return build(.jsonb_populate_record, body: parts)
        }
        
        /// Expands the outermost array of objects in from_json to a set of rows whose columns match the record type defined by base (see note below).
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_populate_recordset(base: SwifQLable, from_json: SwifQLable) -> SwifQLable {
            var parts: [SwifQLPart] = base.parts
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(contentsOf: from_json.parts)
            return build(.jsonb_populate_recordset, body: parts)
        }
        
        /// Expands a JSON array to a set of JSON values.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_array_elements(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_array_elements, body: aggregateExpression.parts)
        }
        
        /// Expands a JSON array to a set of text values.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_array_elements_text(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_array_elements_text, body: aggregateExpression.parts)
        }
        
        /// Returns the type of the outermost JSON value as a text string. Possible types are object, array, string, number, boolean, and null.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_typeof(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_typeof, body: aggregateExpression.parts)
        }
        
        /// Builds an arbitrary record from a JSON object (see note below). As with all functions returning record, the caller must explicitly define the structure of the record with an AS clause.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_to_record(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_to_record, body: aggregateExpression.parts)
        }
        
        /// Builds an arbitrary set of records from a JSON array of objects (see note below). As with all functions returning record, the caller must explicitly define the structure of the record with an AS clause.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_to_recordset(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_to_recordset, body: aggregateExpression.parts)
        }
        
        /// Returns from_json with all object fields that have null values omitted. Other null values are untouched.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_strip_nulls(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_strip_nulls, body: aggregateExpression.parts)
        }
        
        /// Returns target with the section designated by path replaced by new_value,
        /// or with new_value added if create_missing is true ( default is true)
        /// and the item designated by path does not exist.
        /// As with the path orientated operators, negative integers
        /// that appear in path count from the end of JSON arrays.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    //    public static func jsonb_set(target: SwifQLable, path text: [String], new_value: SwifQLable, create_missing: Bool? = nil) -> SwifQLable { // TDB
    //        return _buildFn(.jsonb_set, body: aggregateExpression.parts)
    //    }
        
        /// Returns target with new_value inserted.
        /// If target section designated by path is in a JSONB array,
        /// new_value will be inserted before target or after if insert_after is true (default is false).
        /// If target section designated by path is in JSONB object, new_value will be inserted
        /// only if target does not exist. As with the path orientated operators, negative integers
        /// that appear in path count from the end of JSON arrays.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
    //    public static func jsonb_insert(target: SwifQLable, path text: [String], new_value: SwifQLable, insert_after: Bool? = nil) -> SwifQLable { // TDB
    //        return _buildFn(.jsonb_insert, body: aggregateExpression.parts)
    //    }
        
        /// Returns from_json as indented JSON text.
        /// [Learn more →](https://www.postgresql.org/docs/current/functions-json.html)
        public static func jsonb_pretty(_ aggregateExpression: SwifQLable) -> SwifQLable {
            build(.jsonb_pretty, body: aggregateExpression.parts)
        }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+PostgresSeries.swift
================================================
//
//  Functions+PostgresSeries.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var generate_series: Self = .init("generate_series")
}

extension Fn {
    /// Generate series
    /// # Example
    /// ```swift
    /// Fn.generate_series(1, 4)
    /// Fn.generate_series(1, 4, 2)
    /// Fn.generate_series('2019-10-01', '2019-10-04', '1 day')
    /// ```
    /// # Result
    /// ```
    /// 1, 2, 3, 4
    /// 1, 3
    /// 2019-10-01, 2019-10-02, 2019-10-03, 2019-10-04
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-srf.html)
    public static func generate_series(_ start: SwifQLable, _ stop: SwifQLable, _ step: SwifQLable? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = start.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: stop.parts)
        if let step = step {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(contentsOf: step.parts)
        }
        return build(.generate_series, body: parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+PostgresTime.swift
================================================
//
//  Functions+PostgresTime.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var age: Self = .init("age")
    public static var clock_timestamp: Self = .init("clock_timestamp")
    public static var current_date: Self = .init("current_date")
    public static var current_time: Self = .init("current_time")
    public static var current_timestamp: Self = .init("current_timestamp")
    public static var date_part: Self = .init("date_part")
    public static var date_trunc: Self = .init("date_trunc")
    public static var extract: Self = .init("extract")
    public static var isfinite: Self = .init("isfinite")
    public static var justify_days: Self = .init("justify_days")
    public static var justify_hours: Self = .init("justify_hours")
    public static var justify_interval: Self = .init("justify_interval")
    public static var localtime: Self = .init("localtime")
    public static var localtimestamp: Self = .init("localtimestamp")
    public static var make_date: Self = .init("make_date")
    public static var make_interval: Self = .init("make_interval")
    public static var make_time: Self = .init("make_time")
    public static var make_timestamp: Self = .init("make_timestamp")
    public static var make_timestamptz: Self = .init("make_timestamptz")
    public static var now: Self = .init("now")
    public static var statement_timestamp: Self = .init("statement_timestamp")
    public static var timeofday: Self = .init("timeofday")
    public static var transaction_timestamp: Self = .init("transaction_timestamp")
    public static var to_timestamp: Self = .init("to_timestamp")
}

extension Fn {
    /// Subtract arguments, producing a “symbolic” result that uses years and months, rather than just days
    /// # Example
    /// ```swift
    /// Fn.age("2001-04-10" => .timestamp, "1957-06-13" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 43 years 9 mons 27 days
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func age(_ timestamp1: SwifQLable, _ timestamp2: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = timestamp1.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: timestamp2.parts)
        return build(.age, body: parts)
    }
    
    /// Subtract from current_date (at midnight)
    /// # Example
    /// ```swift
    /// Fn.age("2001-04-10" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 43 years 8 mons 3 days
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func age(_ timestamp1: SwifQLable) -> SwifQLable {
        build(.age, body: timestamp1.parts)
    }
    
    /// Current date and time (changes during statement execution)
    /// # Example
    /// ```swift
    /// Fn.clock_timestamp()
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT)
    public static func clock_timestamp() -> SwifQLable {
        build(.clock_timestamp, body: [])
    }
    
    /// Current date
    /// # Example
    /// ```swift
    /// Fn.current_date
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT)
    public static var current_date: SwifQLable {
        SwifQLableParts(parts: Name.current_date.part)
    }
    
    /// Current time of day
    /// # Example
    /// ```swift
    /// Fn.current_time
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT)
    public static func current_time(_ aggregateExpression: SwifQLable) -> SwifQLable {
        SwifQLableParts(parts: Name.current_time.part)
    }
    
    /// Current date and time (start of current transaction)
    /// # Example
    /// ```swift
    /// Fn.current_timestamp
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT)
    public static func current_timestamp(_ aggregateExpression: SwifQLable) -> SwifQLable {
        SwifQLableParts(parts: Name.current_timestamp.part)
    }
    
    /// Get subfield (equivalent to extract)
    /// # Example with timestamp
    /// ```swift
    /// Fn.date_part("hour", "2001-02-16 20:38:40" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 20
    /// ```
    /// # Example with interval
    /// ```swift
    /// Fn.date_part("month", "2 years 3 months" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 3
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT)
    public static func date_part(_ text: SwifQLable, _ value: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = text.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: value.parts)
        return build(.date_part, body: parts)
    }
    
    /// Truncate to specified precision
    /// # Example with timestamp
    /// ```swift
    /// Fn.date_trunc("hour", "2001-02-16 20:38:40" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 2001-02-16 20:00:00
    /// ```
    /// # Example with interval
    /// ```swift
    /// Fn.date_trunc("hour", "2 days 3 hours 40 minutes" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 2 days 03:00:00
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC)
    public static func date_trunc(_ text: SwifQLable, _ value: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = text.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: value.parts)
        return build(.date_trunc, body: parts)
    }
    
    /// Get subfield
    /// # Example with timestamp
    /// ```swift
    /// Fn.extract(.hour, "2001-02-16 20:38:40" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 20
    /// ```
    /// # Example with interval
    /// ```swift
    /// Fn.extract(.month, "2 years 3 months" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 3
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT)
    public static func extract(_ field: ExtractFieldValue, from value: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = []
        parts.append(safe: field.value)
        parts.append(o: .space)
        parts.append(o: .from)
        parts.append(o: .space)
        parts.append(contentsOf: value.parts)
        return build(.extract, body: parts)
    }
    
    /// Get subfield
    /// # Example with timestamp
    /// ```swift
    /// Fn.extract("hour", "2001-02-16 20:38:40" => .timestamp)
    /// ```
    /// # Result
    /// ```
    /// 20
    /// ```
    /// # Example with interval
    /// ```swift
    /// Fn.extract("month", "2 years 3 months" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 3
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT)
    public static func extract(_ field: SwifQLable, from value: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = field.parts
        parts.append(o: .space)
        parts.append(o: .from)
        parts.append(o: .space)
        parts.append(contentsOf: value.parts)
        return build(.extract, body: parts)
    }
    
    /// Test for finite date (not +/-infinity)
    /// # Example
    /// ```swift
    /// Fn.isfinite("4 hours" => .interval)
    /// ```
    /// # Result
    /// ```
    /// true
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func isfinite(_ interval: SwifQLable) -> SwifQLable {
        build(.isfinite, body: interval.parts)
    }
    
    /// Adjust interval so 30-day time periods are represented as months
    /// # Example
    /// ```swift
    /// Fn.justify_days("35 days" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 1 mon 5 days
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func justify_days(_ interval: SwifQLable) -> SwifQLable {
        build(.justify_days, body: interval.parts)
    }
    
    /// Adjust interval so 24-hour time periods are represented as days
    /// # Example
    /// ```swift
    /// Fn.justify_hours("27 hours" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 1 day 03:00:00
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func justify_hours(_ interval: SwifQLable) -> SwifQLable {
        build(.justify_hours, body: interval.parts)
    }
    
    /// Adjust interval using justify_days and justify_hours, with additional sign adjustments
    /// # Example
    /// ```swift
    /// Fn.justify_interval("1 mon -1 hour" => .interval)
    /// ```
    /// # Result
    /// ```
    /// 29 days 23:00:00
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func justify_interval(_ interval: SwifQLable) -> SwifQLable {
        build(.justify_interval, body: interval.parts)
    }
    
    /// Current time of day
    /// # Example
    /// ```swift
    /// Fn.localtime
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static var localtime: SwifQLable {
        SwifQLableParts(parts: Name.localtime.part)
    }
    
    /// Current date and time (start of current transaction)
    /// # Example
    /// ```swift
    /// Fn.localtimestamp
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static var localtimestamp: SwifQLable {
        SwifQLableParts(parts: Name.localtimestamp.part)
    }
    
    /// Create date from year, month and day fields
    /// # Example
    /// ```swift
    /// Fn.make_date(2013, 7, 15)
    /// ```
    /// # Result
    /// ```
    /// 2013-07-15
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func make_date(_ year: SwifQLable, _ month: SwifQLable, _ day: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = year.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: month.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: day.parts)
        return build(.make_date, body: parts)
    }
    
    /// Create interval from years, months, weeks, days, hours, minutes and seconds fields
    /// # Example
    /// ```swift
    /// Fn.make_interval(days: 10)
    /// ```
    /// # Result
    /// ```
    /// 10 days
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func make_interval(years: SwifQLable? = nil,
                                                   months: SwifQLable? = nil,
                                                   weeks: SwifQLable? = nil,
                                                   days: SwifQLable? = nil,
                                                   hours: SwifQLable? = nil,
                                                   mins: SwifQLable? = nil,
                                                   secs: SwifQLable? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = []
        if let years = years {
            parts.append(o: .custom("years => "))
            if let number = years as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: years.parts)
            }
        }
        if let months = months {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("months => "))
            if let number = months as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: months.parts)
            }
        }
        if let weeks = weeks {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("weeks => "))
            if let number = weeks as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: weeks.parts)
            }
        }
        if let days = days {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("days => "))
            if let number = days as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: days.parts)
            }
        }
        if let hours = hours {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("hours => "))
            if let number = hours as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: hours.parts)
            }
        }
        if let mins = mins {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("mins => "))
            if let number = mins as? Int {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: mins.parts)
            }
        }
        if let secs = secs {
            if parts.count > 0 { parts.append(o: .comma, .space) }
            parts.append(o: .custom("secs => "))
            if let number = secs as? Int {
                parts.append(o: .custom("\(number)"))
            } else if let number = secs as? Double {
                parts.append(o: .custom("\(number)"))
            } else {
                parts.append(contentsOf: secs.parts)
            }
        }
        return build(.make_interval, body: parts)
    }
    
    /// Create time from hour, minute and seconds fields
    /// # Example
    /// ```swift
    /// Fn.make_time(8, 15, 23.5)
    /// ```
    /// # Result
    /// ```
    /// 08:15:23.5
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func make_time(_ hour: SwifQLable, _ min: SwifQLable, _ sec: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = hour.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: min.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: sec.parts)
        return build(.make_time, body: parts)
    }
    
    /// Create timestamp from year, month, day, hour, minute and seconds fields
    /// # Example
    /// ```swift
    /// Fn.make_timestamp(2013, 7, 15, 8, 15, 23.5)
    /// ```
    /// # Result
    /// ```
    /// 2013-07-15 08:15:23.5
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func make_timestamp(_ year: SwifQLable,
                                                       _ month: SwifQLable,
                                                       _ day: SwifQLable,
                                                       _ hour: SwifQLable,
                                                       _ min: SwifQLable,
                                                       _ sec: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = year.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: month.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: day.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: hour.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: min.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: sec.parts)
        return build(.make_timestamp, body: parts)
    }
    
    /// Create timestamp with time zone from year, month, day, hour, minute and seconds fields;
    /// if timezone is not specified, the current time zone is used
    /// # Example
    /// ```swift
    /// Fn.make_timestamptz(2013, 7, 15, 8, 15, 23.5)
    /// ```
    /// # Result
    /// ```
    /// 2013-07-15 08:15:23.5+01
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func make_timestamptz(_ year: SwifQLable,
                                                          _ month: SwifQLable,
                                                          _ day: SwifQLable,
                                                          _ hour: SwifQLable,
                                                          _ min: SwifQLable,
                                                          _ sec: SwifQLable,
                                                          _ timezone: SwifQLable? = nil) -> SwifQLable {
        var parts: [SwifQLPart] = year.parts
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: month.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: day.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: hour.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: min.parts)
        parts.append(o: .comma)
        parts.append(o: .space)
        parts.append(contentsOf: sec.parts)
        if let timezone = timezone {
            parts.append(o: .comma)
            parts.append(o: .space)
            parts.append(contentsOf: timezone.parts)
        }
        return build(.make_timestamptz, body: parts)
    }
    
    /// Current date and time (start of current transaction)
    /// # Example
    /// ```swift
    /// Fn.now()
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func now() -> SwifQLable {
        build(.now, body: [])
    }
    
    /// Current date and time (start of current statement)
    /// # Example
    /// ```swift
    /// Fn.statement_timestamp()
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func statement_timestamp() -> SwifQLable {
        build(.statement_timestamp, body: [])
    }
    
    /// Current date and time (like clock_timestamp, but as a text string)
    /// # Example
    /// ```swift
    /// Fn.timeofday()
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func timeofday() -> SwifQLable {
        build(.timeofday, body: [])
    }
    
    /// Current date and time (start of current transaction)
    /// # Example
    /// ```swift
    /// Fn.transaction_timestamp()
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func transaction_timestamp() -> SwifQLable {
        build(.transaction_timestamp, body: [])
    }
    
    /// Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to timestamp
    /// # Example
    /// ```swift
    /// Fn.to_timestamp(1284352323)
    /// ```
    /// # Result
    /// ```
    /// 2010-09-13 04:32:03+00
    /// ```
    ///
    /// [Learn more →](https://www.postgresql.org/docs/11/functions-datetime.html)
    public static func to_timestamp(_ value: SwifQLable) -> SwifQLable {
        build(.to_timestamp, body: value.parts)
    }
}


================================================
FILE: Sources/SwifQL/Functions/Functions+String.swift
================================================
//
//  Functions+String.swift
//  SwifQL
//
//  Created by Mihael Isaev on 22.05.2020.
//

extension Fn.Name {
    public static var bit_length: Self = .init("bit_length")
    public static var btrim: Self = .init("btrim")
    public static var char_length: Self = .init("char_length")
    public static var character_length: Self = .init("character_length")
    public static var initcap: Self = .init("initcap")
    public static var concat: Self = .init("concat")
    public static var concat_ws: Self = .init("concat_ws")
    public static var array_length: Self = .init("array_length")
    public static var length: Self = .init("length")
    public static var lower: Self = .init("lower")
    public static var lpad: Self = .init("lpad")
    public static var ltrim: Self = .init("ltrim")
    public static var position: Self = .init("position")
    public static var `repeat`: Self = .init("repeat")
    public static var replace: Self = .init("replace")
    public static var rpad: Self = .init("rpad")
    public static var rtrim: Self = .init("rtrim")
    public static var strpos: Self = .init("strpos")
    public static var substring: Self = .init("substring")
    public static var translate: Self = .init("translate")
    public static var trim: Self = .init("trim")
    public static var upper: Self = .init("upper")
    public static var string_agg: Self = .init("string_agg")
    public static var regexp_replace: Self = .init("regexp_replace")
} 

extension Fn {
    /// String and non-string concatenation
    /// e.g. `'Post' || 'greSQL'` will return `PostgreSQL`
    /// so in Swift you can write it like `"Post" || "greSQL"`
    /// or using KeyPath like \User.firstName || " " || \User.lastName
    /// and KeyPath alias like u+\.firstName || " " || u+\.lastName
    /// [Learn more →](https://www.techonthenet.com/postgresql/functions/concat2.php)
    public static func concatStrings(lhs: SwifQLable, rhs: SwifQLable) -> SwifQLable {
        var parts: [SwifQLPart] = lhs.parts
        parts.append(o: .space)
        parts.append(o: .custom("||"))
        parts.append(o: .space)
        parts.append(contentsOf: rhs.parts)
        return SwifQLableParts(parts: parts)
    }
    
    /// Number of bits in string
    /// e.g. `bit_length('jose')` will return 32
    /// [Learn more →]()
    public static func bit_length(_ string: SwifQLable) -> SwifQLable {
        build(.bit_length, body: string.parts)
    }
    
    /// Removes all specified characters from both the beginning and the end of a string
    /// [Learn more →](https://www.techonthenet.com
Download .txt
gitextract_0k67_6b0/

├── .github/
│   └── workflows/
│       └── test.yml
├── .gitignore
├── LICENSE
├── Package.swift
├── README.md
├── Sources/
│   └── SwifQL/
│       ├── Alias.swift
│       ├── Builders/
│       │   ├── CaseWhen.swift
│       │   ├── Distinct.swift
│       │   ├── GenericTableSelector.swift
│       │   ├── NewColumn.swift
│       │   ├── PostgresArray.swift
│       │   ├── PostgresJsonObject.swift
│       │   ├── QueryBuilder.swift
│       │   ├── Schema/
│       │   │   ├── CreateSchemaBuilder.swift
│       │   │   ├── DropSchemaBuilder.swift
│       │   │   ├── UpdateSchemaChangeOwner.swift
│       │   │   └── UpdateSchemaRename.swift
│       │   ├── SwifQLJoinBuilder.swift
│       │   ├── SwifQLSelectBuilder.swift
│       │   ├── Table/
│       │   │   ├── CreateTableBuilder.swift
│       │   │   ├── DropTableBuilder.swift
│       │   │   └── UpdateTableBuilder.swift
│       │   ├── Union.swift
│       │   └── With.swift
│       ├── Codable.swift
│       ├── Column.swift
│       ├── Constraint.swift
│       ├── Dialect/
│       │   ├── Dialect+MySQL.swift
│       │   ├── Dialect+Postgres.swift
│       │   └── Dialect.swift
│       ├── Enum.swift
│       ├── Extensions/
│       │   ├── Array+SwifQLable.swift
│       │   ├── Column+AutoType.swift
│       │   ├── Decodable+Table.swift
│       │   └── StringExtensions.swift
│       ├── ExtractFieldValue.swift
│       ├── FluentKitFieldable.swift
│       ├── FormattedKeyPath.swift
│       ├── Formatter.swift
│       ├── Functions/
│       │   ├── Functions+Array.swift
│       │   ├── Functions+General.swift
│       │   ├── Functions+MySQL.swift
│       │   ├── Functions+Numeric.swift
│       │   ├── Functions+PostgresBool.swift
│       │   ├── Functions+PostgresJSON.swift
│       │   ├── Functions+PostgresJSONB.swift
│       │   ├── Functions+PostgresSeries.swift
│       │   ├── Functions+PostgresTime.swift
│       │   ├── Functions+String.swift
│       │   ├── Functions+TextSearch.swift
│       │   ├── Functions+Window.swift
│       │   └── Functions.swift
│       ├── HybridOperator.swift
│       ├── IndexItem.swift
│       ├── IndexType.swift
│       ├── KeyPath.swift
│       ├── Keypathable.swift
│       ├── Operators.swift
│       ├── Parts/
│       │   ├── AliasPart.swift
│       │   ├── ArrayPart.swift
│       │   ├── BoolPart.swift
│       │   ├── ColumnPart.swift
│       │   ├── DatePart.swift
│       │   ├── HybridOperatorPart.swift
│       │   ├── KeyPathPart.swift
│       │   ├── NullPart.swift
│       │   ├── OperatorPart.swift
│       │   ├── SafeValuePart.swift
│       │   ├── TablePart.swift
│       │   ├── TableWithAliasPart.swift
│       │   └── UnsafeValuePart.swift
│       ├── Path/
│       │   ├── Path+Column.swift
│       │   ├── Path+Schema.swift
│       │   ├── Path+SchemaWithTable.swift
│       │   ├── Path+SchemaWithTableAndColumn.swift
│       │   ├── Path+Table.swift
│       │   ├── Path+TableWithColumn.swift
│       │   └── Path.swift
│       ├── Predicates.swift
│       ├── Prepared.swift
│       ├── QueryBuilderable.swift
│       ├── QueryParts.swift
│       ├── ReferentialAction.swift
│       ├── ResultBuilders/
│       │   └── SwifQLableResultBuilder.swift
│       ├── Schema.swift
│       ├── Schemable.swift
│       ├── SplittedQuery.swift
│       ├── SwifQL.swift
│       ├── SwifQLable+Parts/
│       │   ├── SwifQLable+Action.swift
│       │   ├── SwifQLable+Add.swift
│       │   ├── SwifQLable+AddQuery.swift
│       │   ├── SwifQLable+After.swift
│       │   ├── SwifQLable+All.swift
│       │   ├── SwifQLable+Alter.swift
│       │   ├── SwifQLable+And.swift
│       │   ├── SwifQLable+Any.swift
│       │   ├── SwifQLable+As.swift
│       │   ├── SwifQLable+Asterisk.swift
│       │   ├── SwifQLable+Before.swift
│       │   ├── SwifQLable+Begin.swift
│       │   ├── SwifQLable+Between.swift
│       │   ├── SwifQLable+Cascade.swift
│       │   ├── SwifQLable+Check.swift
│       │   ├── SwifQLable+Column.swift
│       │   ├── SwifQLable+Commit.swift
│       │   ├── SwifQLable+Conflict.swift
│       │   ├── SwifQLable+Constraint.swift
│       │   ├── SwifQLable+Create.swift
│       │   ├── SwifQLable+Default.swift
│       │   ├── SwifQLable+Delete.swift
│       │   ├── SwifQLable+Distinct.swift
│       │   ├── SwifQLable+Do.swift
│       │   ├── SwifQLable+Drop.swift
│       │   ├── SwifQLable+End.swift
│       │   ├── SwifQLable+Epoch.swift
│       │   ├── SwifQLable+Exists.swift
│       │   ├── SwifQLable+Filter.swift
│       │   ├── SwifQLable+From.swift
│       │   ├── SwifQLable+Fulltext.swift
│       │   ├── SwifQLable+Function.swift
│       │   ├── SwifQLable+GroupBy.swift
│       │   ├── SwifQLable+Having.swift
│       │   ├── SwifQLable+ILike.swift
│       │   ├── SwifQLable+If.swift
│       │   ├── SwifQLable+In.swift
│       │   ├── SwifQLable+InsertInto.swift
│       │   ├── SwifQLable+Interval.swift
│       │   ├── SwifQLable+IsNotNull.swift
│       │   ├── SwifQLable+IsNull.swift
│       │   ├── SwifQLable+Items.swift
│       │   ├── SwifQLable+Join.swift
│       │   ├── SwifQLable+Key.swift
│       │   ├── SwifQLable+Like.swift
│       │   ├── SwifQLable+Limit.swift
│       │   ├── SwifQLable+No.swift
│       │   ├── SwifQLable+Not.swift
│       │   ├── SwifQLable+NotBetween.swift
│       │   ├── SwifQLable+NotExists.swift
│       │   ├── SwifQLable+NotILike.swift
│       │   ├── SwifQLable+NotIn.swift
│       │   ├── SwifQLable+NotLike.swift
│       │   ├── SwifQLable+Nothing.swift
│       │   ├── SwifQLable+Null.swift
│       │   ├── SwifQLable+Offset.swift
│       │   ├── SwifQLable+On.swift
│       │   ├── SwifQLable+Or.swift
│       │   ├── SwifQLable+OrderBy.swift
│       │   ├── SwifQLable+Over.swift
│       │   ├── SwifQLable+Overlaps.swift
│       │   ├── SwifQLable+Owner.swift
│       │   ├── SwifQLable+PartitionBy.swift
│       │   ├── SwifQLable+Primary.swift
│       │   ├── SwifQLable+Raw.swift
│       │   ├── SwifQLable+References.swift
│       │   ├── SwifQLable+Rename.swift
│       │   ├── SwifQLable+Restrict.swift
│       │   ├── SwifQLable+Return.swift
│       │   ├── SwifQLable+Returning.swift
│       │   ├── SwifQLable+Rollback.swift
│       │   ├── SwifQLable+Schema.swift
│       │   ├── SwifQLable+Select.swift
│       │   ├── SwifQLable+Semicolon.swift
│       │   ├── SwifQLable+Set.swift
│       │   ├── SwifQLable+Space.swift
│       │   ├── SwifQLable+Subscript.swift
│       │   ├── SwifQLable+Table.swift
│       │   ├── SwifQLable+Timestamp.swift
│       │   ├── SwifQLable+To.swift
│       │   ├── SwifQLable+Type.swift
│       │   ├── SwifQLable+Union.swift
│       │   ├── SwifQLable+Unique.swift
│       │   ├── SwifQLable+Update.swift
│       │   ├── SwifQLable+Value.swift
│       │   ├── SwifQLable+Values.swift
│       │   ├── SwifQLable+Where.swift
│       │   ├── SwifQLable+WhereExists.swift
│       │   ├── SwifQLable+WhereNotExists.swift
│       │   ├── SwifQLable+Window.swift
│       │   └── SwifQLable+With.swift
│       ├── SwifQLable.swift
│       ├── SwifQLableArraySeparator.swift
│       ├── Table.swift
│       ├── TableAlias.swift
│       ├── Type+Autodetect.swift
│       ├── Type+SwifQLable.swift
│       ├── Type.swift
│       └── _Todo.swift
└── Tests/
    └── SwifQLTests/
        ├── BuilderTests.swift
        ├── CaseTests.swift
        ├── DirectiveTests.swift
        ├── ExistsTests.swift
        ├── FnTests.swift
        ├── FromTests.swift
        ├── JsonTests.swift
        ├── OrderTests.swift
        ├── OtherTests.swift
        ├── PredicateTest.swift
        ├── SelectTests.swift
        ├── SubqueryTests.swift
        ├── SwifQLTestCase.swift
        ├── TableEncoding.swift
        └── WithTests.swift
Condensed preview — 202 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (489K chars).
[
  {
    "path": ".github/workflows/test.yml",
    "chars": 172,
    "preview": "name: test\non: [push, pull_request]\njobs:\n  swift_6_0:\n    container: swift:6.0\n    runs-on: ubuntu-latest\n    steps:\n  "
  },
  {
    "path": ".gitignore",
    "chars": 77,
    "preview": "Packages\n.build\n.DS_Store\n*.xcodeproj\nDerivedData/\nPackage.resolved\n.swiftpm\n"
  },
  {
    "path": "LICENSE",
    "chars": 1069,
    "preview": "MIT License\n\nCopyright (c) 2018 Mihael Isaev\n\nPermission is hereby granted, free of charge, to any person obtaining a co"
  },
  {
    "path": "Package.swift",
    "chars": 542,
    "preview": "// swift-tools-version:6.0\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"SwifQL\",\n    platforms: [\n     "
  },
  {
    "path": "README.md",
    "chars": 18883,
    "preview": "[![Mihael Isaev](https://user-images.githubusercontent.com/1272610/53677263-7ecbfe00-3cc6-11e9-9049-2d2b9a2d7947.png)](h"
  },
  {
    "path": "Sources/SwifQL/Alias.swift",
    "chars": 6576,
    "preview": "//\n//  Alias.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 19.04.2020.\n//\n\nimport Foundation\n\npublic protocol AnyAl"
  },
  {
    "path": "Sources/SwifQL/Builders/CaseWhen.swift",
    "chars": 1594,
    "preview": "//\n//  SwifQLable+Case.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 15/02/2019.\n//\n\nimport Foundation\n\npublic clas"
  },
  {
    "path": "Sources/SwifQL/Builders/Distinct.swift",
    "chars": 1673,
    "preview": "//\n//  Distinct.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/03/2019.\n//\n\nimport Foundation\n\n//MARK: DISTINCT\n\n"
  },
  {
    "path": "Sources/SwifQL/Builders/GenericTableSelector.swift",
    "chars": 22084,
    "preview": "//\n//  GenericTableSelector.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 31.01.2020.\n//\n\nextension Table {\n    pub"
  },
  {
    "path": "Sources/SwifQL/Builders/NewColumn.swift",
    "chars": 2571,
    "preview": "//\n//  NewColumn.swift\n//  \n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\npublic class NewColumn:"
  },
  {
    "path": "Sources/SwifQL/Builders/PostgresArray.swift",
    "chars": 1121,
    "preview": "//\n//  PostgresArray.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\npublic typeal"
  },
  {
    "path": "Sources/SwifQL/Builders/PostgresJsonObject.swift",
    "chars": 1830,
    "preview": "//\n//  PostgresJsonObject.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\npublic t"
  },
  {
    "path": "Sources/SwifQL/Builders/QueryBuilder.swift",
    "chars": 2365,
    "preview": "//\n//  QueryBuilder.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 19.12.2019.\n//\n\nimport Foundation\n\npublic pro"
  },
  {
    "path": "Sources/SwifQL/Builders/Schema/CreateSchemaBuilder.swift",
    "chars": 603,
    "preview": "//\n//  CreateSchemaBuilder.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\npublic class CreateSchemaB"
  },
  {
    "path": "Sources/SwifQL/Builders/Schema/DropSchemaBuilder.swift",
    "chars": 581,
    "preview": "//\n//  DropSchemaBuilder.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\npublic class DropSchemaBuild"
  },
  {
    "path": "Sources/SwifQL/Builders/Schema/UpdateSchemaChangeOwner.swift",
    "chars": 580,
    "preview": "//\n//  UpdateSchemaChangeOwner.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\npublic class UpdateSch"
  },
  {
    "path": "Sources/SwifQL/Builders/Schema/UpdateSchemaRename.swift",
    "chars": 574,
    "preview": "//\n//  UpdateSchemaRename.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\npublic class UpdateSchemaRe"
  },
  {
    "path": "Sources/SwifQL/Builders/SwifQLJoinBuilder.swift",
    "chars": 2292,
    "preview": "//\n//  SwifQLJoinBuilder.swift\n//  App\n//\n//  Created by Mihael Isaev on 22/02/2019.\n//\n\nimport Foundation\n\npublic struc"
  },
  {
    "path": "Sources/SwifQL/Builders/SwifQLSelectBuilder.swift",
    "chars": 1383,
    "preview": "//\n//  SwifQLSelectBuilder.swift\n//  App\n//\n//  Created by Mihael Isaev on 22/02/2019.\n//\n\nimport Foundation\n\npublic cla"
  },
  {
    "path": "Sources/SwifQL/Builders/Table/CreateTableBuilder.swift",
    "chars": 3038,
    "preview": "//\n//  CreateTableBuilder.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\npublic class CreateTableBui"
  },
  {
    "path": "Sources/SwifQL/Builders/Table/DropTableBuilder.swift",
    "chars": 562,
    "preview": "//\n//  DropTableBuilder.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\npublic class DropTableBuilder"
  },
  {
    "path": "Sources/SwifQL/Builders/Table/UpdateTableBuilder.swift",
    "chars": 22362,
    "preview": "//\n//  UpdateTableBuilder.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\npublic class UpdateTableBui"
  },
  {
    "path": "Sources/SwifQL/Builders/Union.swift",
    "chars": 743,
    "preview": "//\n//  Union.swift\n//  SwifQL\n//\n//  Created by Taylor McIntyre on 2020-01-15.\n//\n\nimport Foundation\n\n//MARK: UNION\n\npub"
  },
  {
    "path": "Sources/SwifQL/Builders/With.swift",
    "chars": 934,
    "preview": "//\n//  With.swift\n//  SwifQL\n//\n//  Created by Taylor McIntyre on 2020-01-16.\n//\n\nimport Foundation\n\n//MARK: WITH\n\npubli"
  },
  {
    "path": "Sources/SwifQL/Codable.swift",
    "chars": 476,
    "preview": "//\n//  Codable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 25.04.2020.\n//\n\nimport Foundation\n\npublic protocol Swi"
  },
  {
    "path": "Sources/SwifQL/Column.swift",
    "chars": 4692,
    "preview": "//\n//  Column.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\npublic protocol AnyC"
  },
  {
    "path": "Sources/SwifQL/Constraint.swift",
    "chars": 1888,
    "preview": "//\n//  Constraint.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 19.04.2020.\n//\n\nimport Foundation\n\npublic struct Co"
  },
  {
    "path": "Sources/SwifQL/Dialect/Dialect+MySQL.swift",
    "chars": 1039,
    "preview": "//\n//  Dialect+MySQL.swift\n//\n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nclass MySQLDialect: S"
  },
  {
    "path": "Sources/SwifQL/Dialect/Dialect+Postgres.swift",
    "chars": 2591,
    "preview": "//\n//  Dialect+Postgres.swift\n//\n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nclass PostgreSQLDi"
  },
  {
    "path": "Sources/SwifQL/Dialect/Dialect.swift",
    "chars": 3300,
    "preview": "//\n//  Dialect.swift\n//\n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nopen class SQLDialect {\n   "
  },
  {
    "path": "Sources/SwifQL/Enum.swift",
    "chars": 1188,
    "preview": "//\n//  Enum.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic protocol AnySwi"
  },
  {
    "path": "Sources/SwifQL/Extensions/Array+SwifQLable.swift",
    "chars": 1219,
    "preview": "//\n//  Array+SwifQLable.swift\n//\n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\nextension Array: S"
  },
  {
    "path": "Sources/SwifQL/Extensions/Column+AutoType.swift",
    "chars": 6125,
    "preview": "//\n//  Column+AutoType.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\nextension C"
  },
  {
    "path": "Sources/SwifQL/Extensions/Decodable+Table.swift",
    "chars": 587,
    "preview": "//\n//  Decodable+Table.swift\n//  \n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\nextension Decodab"
  },
  {
    "path": "Sources/SwifQL/Extensions/StringExtensions.swift",
    "chars": 721,
    "preview": "//\n//  StringExtensions.swift\n//  App\n//\n//  Created by Mihael Isaev on 06.06.2018.\n//\n\nimport Foundation\n\nextension Str"
  },
  {
    "path": "Sources/SwifQL/ExtractFieldValue.swift",
    "chars": 5765,
    "preview": "//\n//  ExtractFieldValue.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29/10/2019.\n//\n\npublic struct ExtractFieldVa"
  },
  {
    "path": "Sources/SwifQL/FluentKitFieldable.swift",
    "chars": 98,
    "preview": "public protocol FluentKitFieldable {\n    var schema: String { get }\n    var key: String { get }\n}\n"
  },
  {
    "path": "Sources/SwifQL/FormattedKeyPath.swift",
    "chars": 1687,
    "preview": "//\n//  FormattedKeyPath.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 20/06/2019.\n//\n\nimport Foundation\n\n/// Format"
  },
  {
    "path": "Sources/SwifQL/Formatter.swift",
    "chars": 2335,
    "preview": "//\n//  Formatter.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nstruct SwifQLFormatter "
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+Array.swift",
    "chars": 1068,
    "preview": "//\n//  Functions+Array.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    public"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+General.swift",
    "chars": 3074,
    "preview": "//\n//  Functions+General.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    publ"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+MySQL.swift",
    "chars": 1438,
    "preview": "//\n//  Functions+MySQL.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    public"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+Numeric.swift",
    "chars": 6889,
    "preview": "//\n//  Functions+Numeric.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    publ"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+PostgresBool.swift",
    "chars": 560,
    "preview": "//\n//  Functions+PostgresBool.swift\n//  SwifQL\n//\n//  Created by Ethan Lozano on 06.12.20.\n//\n\nimport Foundation\n\nextens"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+PostgresJSON.swift",
    "chars": 13281,
    "preview": "//\n//  Functions+PostgresJSON.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n   "
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+PostgresJSONB.swift",
    "chars": 14808,
    "preview": "//\n//  Functions+PostgresJSONB.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n  "
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+PostgresSeries.swift",
    "chars": 1124,
    "preview": "//\n//  Functions+PostgresSeries.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n "
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+PostgresTime.swift",
    "chars": 20003,
    "preview": "//\n//  Functions+PostgresTime.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n   "
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+String.swift",
    "chars": 16796,
    "preview": "//\n//  Functions+String.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    publi"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+TextSearch.swift",
    "chars": 4032,
    "preview": "//\n//  Functions+TextSearch.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    p"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions+Window.swift",
    "chars": 6843,
    "preview": "//\n//  Functions+Window.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nextension Fn.Name {\n    publi"
  },
  {
    "path": "Sources/SwifQL/Functions/Functions.swift",
    "chars": 2269,
    "preview": "//\n//  Functions.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 04/11/2018.\n//\n\nimport Foundation\n\npublic struct Fn "
  },
  {
    "path": "Sources/SwifQL/HybridOperator.swift",
    "chars": 483,
    "preview": "//\n//  HybridOperator.swift\n//  \n//\n//  Created by TierraCero on 5/30/23.\n//\n\nimport Foundation\n\nextension SwifQLHybridO"
  },
  {
    "path": "Sources/SwifQL/IndexItem.swift",
    "chars": 1955,
    "preview": "//\n//  IndexItem.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 18.08.2020.\n//\n\npublic class IndexItem: SwifQLable {"
  },
  {
    "path": "Sources/SwifQL/IndexType.swift",
    "chars": 855,
    "preview": "//\n//  IndexType.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 18.08.2020.\n//\n\nimport Foundation\n\npublic class Inde"
  },
  {
    "path": "Sources/SwifQL/KeyPath.swift",
    "chars": 8850,
    "preview": "//\n//  KeyPath.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 05/11/2018.\n//\n\nimport Foundation\n\npublic protocol Key"
  },
  {
    "path": "Sources/SwifQL/Keypathable.swift",
    "chars": 854,
    "preview": "//\n//  Keypathable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 11/11/2018.\n//\n\nimport Foundation\n\npublic protocol"
  },
  {
    "path": "Sources/SwifQL/Operators.swift",
    "chars": 20605,
    "preview": "//\n//  Operator.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\npublic typealias O"
  },
  {
    "path": "Sources/SwifQL/Parts/AliasPart.swift",
    "chars": 238,
    "preview": "//\n//  AliasPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct Swi"
  },
  {
    "path": "Sources/SwifQL/Parts/ArrayPart.swift",
    "chars": 190,
    "preview": "//\n//  ArrayPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 06.06.2020.\n//\n\nimport Foundation\n\npublic protocol S"
  },
  {
    "path": "Sources/SwifQL/Parts/BoolPart.swift",
    "chars": 348,
    "preview": "//\n//  BoolPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic typealias S"
  },
  {
    "path": "Sources/SwifQL/Parts/ColumnPart.swift",
    "chars": 250,
    "preview": "//\n//  ColumnPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct Sw"
  },
  {
    "path": "Sources/SwifQL/Parts/DatePart.swift",
    "chars": 242,
    "preview": "//\n//  DatePart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct Swif"
  },
  {
    "path": "Sources/SwifQL/Parts/HybridOperatorPart.swift",
    "chars": 489,
    "preview": "//\n//  HybridOperatorPart.swift\n//  \n//\n//  Created by TierraCero on 5/30/23.\n//\n\nimport Foundation\n\npublic struct SwifQ"
  },
  {
    "path": "Sources/SwifQL/Parts/KeyPathPart.swift",
    "chars": 1011,
    "preview": "//\n//  KeyPathPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct S"
  },
  {
    "path": "Sources/SwifQL/Parts/NullPart.swift",
    "chars": 278,
    "preview": "//\n//  NullPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 31.10.2020.\n//\n\nimport Foundation\n\npublic var SwifQLN"
  },
  {
    "path": "Sources/SwifQL/Parts/OperatorPart.swift",
    "chars": 368,
    "preview": "//\n//  OperatorPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct "
  },
  {
    "path": "Sources/SwifQL/Parts/SafeValuePart.swift",
    "chars": 252,
    "preview": "//\n//  SafeValuePart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct"
  },
  {
    "path": "Sources/SwifQL/Parts/TablePart.swift",
    "chars": 543,
    "preview": "//\n//  TablePart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic struct Swi"
  },
  {
    "path": "Sources/SwifQL/Parts/TableWithAliasPart.swift",
    "chars": 394,
    "preview": "//\n//  TableWithAliasPart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic s"
  },
  {
    "path": "Sources/SwifQL/Parts/UnsafeValuePart.swift",
    "chars": 270,
    "preview": "//\n//  UnsafeValuePart.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\npublic stru"
  },
  {
    "path": "Sources/SwifQL/Path/Path+Column.swift",
    "chars": 610,
    "preview": "//\n//  Path+Column.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 04.01.2020.\n//\n\nimport Foundation\n\nextension Path "
  },
  {
    "path": "Sources/SwifQL/Path/Path+Schema.swift",
    "chars": 776,
    "preview": "//\n//  Path+Schema.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextension Path "
  },
  {
    "path": "Sources/SwifQL/Path/Path+SchemaWithTable.swift",
    "chars": 1039,
    "preview": "//\n//  Path+SchemaWithTable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextens"
  },
  {
    "path": "Sources/SwifQL/Path/Path+SchemaWithTableAndColumn.swift",
    "chars": 562,
    "preview": "//\n//  Path+SchemaWithTableAndColumn.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundatio"
  },
  {
    "path": "Sources/SwifQL/Path/Path+Table.swift",
    "chars": 927,
    "preview": "//\n//  Path+Table.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 07.01.2020.\n//\n\nimport Foundation\n\nextension Path {"
  },
  {
    "path": "Sources/SwifQL/Path/Path+TableWithColumn.swift",
    "chars": 477,
    "preview": "//\n//  TableWithColumn.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 07.01.2020.\n//\n\nimport Foundation\n\nextension P"
  },
  {
    "path": "Sources/SwifQL/Path/Path.swift",
    "chars": 114,
    "preview": "//\n//  Path.swift\n//  \n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\npublic struct Path {}\n"
  },
  {
    "path": "Sources/SwifQL/Predicates.swift",
    "chars": 4220,
    "preview": "//\n//  Predicates.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\npublic struc"
  },
  {
    "path": "Sources/SwifQL/Prepared.swift",
    "chars": 1037,
    "preview": "//\n//  Prepared.swift\n//\n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\npublic struct SwifQLPrepar"
  },
  {
    "path": "Sources/SwifQL/QueryBuilderable.swift",
    "chars": 2426,
    "preview": "//\n//  QueryBuilderable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 18.05.2020.\n//\n\nimport Foundation\n\npublic pro"
  },
  {
    "path": "Sources/SwifQL/QueryParts.swift",
    "chars": 1899,
    "preview": "//\n//  QueryParts.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 18.05.2020.\n//\n\nimport Foundation\n\npublic class Que"
  },
  {
    "path": "Sources/SwifQL/ReferentialAction.swift",
    "chars": 1637,
    "preview": "//\n//  ReferentialAction.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\npublic st"
  },
  {
    "path": "Sources/SwifQL/ResultBuilders/SwifQLableResultBuilder.swift",
    "chars": 2316,
    "preview": "////\n////  SwifQLableResultBuilder.swift\n////  SwifQL\n////\n////  Created by Mihael Isaev on 11.04.2020.\n////\n//\n//import"
  },
  {
    "path": "Sources/SwifQL/Schema.swift",
    "chars": 999,
    "preview": "//\n//  Schema.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\n@dynamicMemberLookup"
  },
  {
    "path": "Sources/SwifQL/Schemable.swift",
    "chars": 948,
    "preview": "//\n//  Schemable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\npublic protocol S"
  },
  {
    "path": "Sources/SwifQL/SplittedQuery.swift",
    "chars": 318,
    "preview": "//\n//  SplittedQuery.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\npublic struct SwifQ"
  },
  {
    "path": "Sources/SwifQL/SwifQL.swift",
    "chars": 796,
    "preview": "//\n//  SwifQL.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 04/11/2018.\n//\n\nimport Foundation\n\npublic let SwifQL: S"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Action.swift",
    "chars": 340,
    "preview": "//\n//  SwifQLable+Action.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK: A"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Add.swift",
    "chars": 328,
    "preview": "//\n//  SwifQLable+Add.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\nextension Sw"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+AddQuery.swift",
    "chars": 363,
    "preview": "//\n//  SwifQLable+AddQuery.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 18.05.2020.\n//\n\nimport Foundation\n\nextensi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+After.swift",
    "chars": 335,
    "preview": "//\n//  SwifQLable+After.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\n//MARK: AF"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+All.swift",
    "chars": 324,
    "preview": "//\n//  SwifQLable+All.swift\n//  App\n//\n//  Created by Mihael Isaev on 30.09.2021.\n//\n\nimport Foundation\n\n//MARK: ALL\n\nex"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Alter.swift",
    "chars": 335,
    "preview": "//\n//  SwifQLable+Alter.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 26/11/2018.\n//\n\nimport Foundation\n\n//MARK: AL"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+And.swift",
    "chars": 627,
    "preview": "//\n//  SwifQLable+And.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Any.swift",
    "chars": 672,
    "preview": "//\n//  SwifQLable+Any.swift\n//\n//\n//  Created by Mihael Isaev on 26.10.2020.\n//\n\nimport Foundation\n\n//MARK: ANY\n\nextensi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+As.swift",
    "chars": 612,
    "preview": "//\n//  SwifQLable+As.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: AS\n\nextensi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Asterisk.swift",
    "chars": 343,
    "preview": "//\n//  SwifQLable+Asterisk.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 31.01.2020.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Before.swift",
    "chars": 339,
    "preview": "//\n//  SwifQLable+Before.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\n//MARK: B"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Begin.swift",
    "chars": 329,
    "preview": "//\n//  SwifQLable+Begin.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: BEGIN\n\ne"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Between.swift",
    "chars": 447,
    "preview": "//\n//  SwifQLable+Between.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MA"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Cascade.swift",
    "chars": 343,
    "preview": "//\n//  SwifQLable+Cascade.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Check.swift",
    "chars": 336,
    "preview": "//\n//  SwifQLable+Check.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK: CH"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Column.swift",
    "chars": 337,
    "preview": "//\n//  SwifQLable+Rename.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 17.08.2020.\n//\n\nimport Foundation\n\nextension"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Commit.swift",
    "chars": 339,
    "preview": "//\n//  SwifQLable+Commit.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\n//MARK: C"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Conflict.swift",
    "chars": 1012,
    "preview": "//\n//  SwifQLable+Conflict.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 24/07/2019.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Constraint.swift",
    "chars": 671,
    "preview": "//\n//  SwifQLable+Constraint.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 24/07/2019.\n//\n\nimport Foundation\n\n//MAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Create.swift",
    "chars": 335,
    "preview": "//\n//  SwifQLable+CreateType.swift\n//  \n//\n//  Created by Mihael Isaev on 23.01.2020.\n//\n\nimport Foundation\n\nextension S"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Default.swift",
    "chars": 345,
    "preview": "//\n//  SwifQLable+Default.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Delete.swift",
    "chars": 697,
    "preview": "//\n//  SwifQLable+Delete.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 26/11/2018.\n//\n\nimport Foundation\n\nextension"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Distinct.swift",
    "chars": 342,
    "preview": "//\n//  SwifQLable+Distinct.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: DISTI"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Do.swift",
    "chars": 325,
    "preview": "//\n//  SwifQLable+Do.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 24/07/2019.\n//\n\nimport Foundation\n\n//MARK: Do\n\ne"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Drop.swift",
    "chars": 331,
    "preview": "//\n//  SwifQLable+Drop.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\nextension S"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+End.swift",
    "chars": 321,
    "preview": "//\n//  SwifQLable+End.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: END\n\nexten"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Epoch.swift",
    "chars": 732,
    "preview": "//\n//  SwifQLable+Epoch.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\n//MARK: Ep"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Exists.swift",
    "chars": 715,
    "preview": "//\n//  SwifQLable+Exists.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 23/07/2019.\n//\n\nimport Foundation\n\n//MARK: E"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Filter.swift",
    "chars": 884,
    "preview": "//\n//  SwifQLable+Filter.swift\n//  App\n//\n//  Created by Mihael Isaev on 01/03/2019.\n//\n\nimport Foundation\n\n//MARK: Filt"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+From.swift",
    "chars": 700,
    "preview": "//\n//  SwifQLable+From.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 13/11/2018.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Fulltext.swift",
    "chars": 445,
    "preview": "//\n//  SwifQLable+Fulltext.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//M"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Function.swift",
    "chars": 339,
    "preview": "//\n//  SwifQLable+Function.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nextension Swi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+GroupBy.swift",
    "chars": 774,
    "preview": "//\n//  SwifQLable+GroupBy.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Having.swift",
    "chars": 451,
    "preview": "//\n//  SwifQLable+Having.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: H"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+ILike.swift",
    "chars": 711,
    "preview": "//\n//  SwifQLable+iLike.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+If.swift",
    "chars": 319,
    "preview": "//\n//  SwifQLable+If.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: IF\n\nextensi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+In.swift",
    "chars": 1691,
    "preview": "//\n//  SwifQLable+In.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK: I"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+InsertInto.swift",
    "chars": 3267,
    "preview": "//\n//  SwifQLable+InsertInto.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 13/11/2018.\n//\n\nimport Foundation\n\ne"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Interval.swift",
    "chars": 654,
    "preview": "//\n//  SwifQLable+Interval.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+IsNotNull.swift",
    "chars": 389,
    "preview": "//\n//  SwifQLable+IsNotNull.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+IsNull.swift",
    "chars": 344,
    "preview": "//\n//  SwifQLable+IsNull.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Items.swift",
    "chars": 1153,
    "preview": "//\n//  SwifQLable+Items.swift\n//  App\n//\n//  Created by Mihael Isaev on 04.02.2020.\n//\n\nimport Foundation\n\nextension Swi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Join.swift",
    "chars": 1239,
    "preview": "//\n//  SwifQLable+Join.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: JOI"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Key.swift",
    "chars": 321,
    "preview": "//\n//  SwifQLable+Key.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: KEY\n\nexten"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Like.swift",
    "chars": 705,
    "preview": "//\n//  SwifQLable+Like.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Limit.swift",
    "chars": 437,
    "preview": "//\n//  SwifQLable+Limit.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: LI"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+No.swift",
    "chars": 324,
    "preview": "//\n//  SwifQLable+No.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK: NO\n\ne"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Not.swift",
    "chars": 612,
    "preview": "//\n//  SwifQLable+Not.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+NotBetween.swift",
    "chars": 295,
    "preview": "//\n//  SwifQLable+NotBetween.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n/"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+NotExists.swift",
    "chars": 596,
    "preview": "//\n//  SwifQLable+NotExists.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 23/07/2019.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+NotILike.swift",
    "chars": 732,
    "preview": "//\n//  SwifQLable+NotILike.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n// "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+NotIn.swift",
    "chars": 1328,
    "preview": "//\n//  SwifQLable+NotIn.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n// MAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+NotLike.swift",
    "chars": 726,
    "preview": "//\n//  SwifQLable+NotLike.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n// M"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Nothing.swift",
    "chars": 343,
    "preview": "//\n//  SwifQLable+Nothing.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 24/07/2019.\n//\n\nimport Foundation\n\n//MARK: "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Null.swift",
    "chars": 629,
    "preview": "//\n//  SwifQLable+Null.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: NULL\n\next"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Offset.swift",
    "chars": 441,
    "preview": "//\n//  SwifQLable+Offset.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: O"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+On.swift",
    "chars": 323,
    "preview": "//\n//  SwifQLable+On.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 24/07/2019.\n//\n\nimport Foundation\n\n//MARK: On\n\ne"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Or.swift",
    "chars": 437,
    "preview": "//\n//  SwifQLable+Or.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK: O"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+OrderBy.swift",
    "chars": 5473,
    "preview": "//\n//  SwifQLable+OrderBy.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\npublic s"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Over.swift",
    "chars": 1436,
    "preview": "//\n//  SwifQLable+Over.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nimport Foundation\n\n//MARK: Ove"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Overlaps.swift",
    "chars": 1091,
    "preview": "//\n//  SwifQLable+Overlaps.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Owner.swift",
    "chars": 334,
    "preview": "//\n//  SwifQLable+Owner.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextension "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+PartitionBy.swift",
    "chars": 912,
    "preview": "//\n//  SwifQLable+PartitionBy.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nimport Foundation\n\n//MA"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Primary.swift",
    "chars": 337,
    "preview": "//\n//  SwifQLable+Primary.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: PRIMAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Raw.swift",
    "chars": 719,
    "preview": "//\n//  SwifQLable+Raw.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 14/02/2019.\n//\n\nimport Foundation\n\n//MARK: Abil"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+References.swift",
    "chars": 356,
    "preview": "//\n//  SwifQLable+References.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Rename.swift",
    "chars": 337,
    "preview": "//\n//  SwifQLable+Rename.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextension"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Restrict.swift",
    "chars": 347,
    "preview": "//\n//  SwifQLable+Restrict.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Return.swift",
    "chars": 319,
    "preview": "//\n//  SwifQLable+Return.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nextension SwifQ"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Returning.swift",
    "chars": 924,
    "preview": "//\n//  SwifQLable+Returning.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 11/07/2019.\n//\n\nimport Foundation\n\nextens"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Rollback.swift",
    "chars": 347,
    "preview": "//\n//  SwifQLable+Rollback.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\n//MARK:"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Schema.swift",
    "chars": 639,
    "preview": "//\n//  SwifQLable+Schema.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextension"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Select.swift",
    "chars": 909,
    "preview": "//\n//  SwifQLable+Select.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 13/11/2018.\n//\n\nimport Foundation\n\n//MAR"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Semicolon.swift",
    "chars": 338,
    "preview": "//\n//  SwifQLable+Semicolon.swift\n//  \n//\n//  Created by Mihael Isaev on 24.01.2020.\n//\n\nimport Foundation\n\nextension Sw"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Set.swift",
    "chars": 614,
    "preview": "//\n//  SwifQLable+Set.swift\n//  \n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\n//MARK: SET\n\nexten"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Space.swift",
    "chars": 347,
    "preview": "//\n//  SwifQLable+Space.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 31.01.2020.\n//\n\nimport Foundation\n\n//MARK: si"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Subscript.swift",
    "chars": 683,
    "preview": "//\n//  SwifQLable+Subscript.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 20/03/2019.\n//\n\nimport Foundation\n\nextens"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Table.swift",
    "chars": 627,
    "preview": "//\n//  SwifQLable+Table.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nextension SwifQL"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Timestamp.swift",
    "chars": 919,
    "preview": "//\n//  SwifQLable+Timestamp.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+To.swift",
    "chars": 325,
    "preview": "//\n//  SwifQLable+To.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12.04.2020.\n//\n\nimport Foundation\n\nextension Swi"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Type.swift",
    "chars": 922,
    "preview": "//\n//  SwifQLable+Type.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\nextension SwifQLa"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Union.swift",
    "chars": 371,
    "preview": "//\n//  SwifQLable+Union.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 16/11/2018.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Unique.swift",
    "chars": 333,
    "preview": "//\n//  SwifQLable+Unique.swift\n//  \n//\n//  Created by Mihael Isaev on 25.01.2020.\n//\n\nimport Foundation\n\n//MARK: UNIQUE\n"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Update.swift",
    "chars": 905,
    "preview": "//\n//  SwifQLable+Update.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 26/11/2018.\n//\n\nimport Foundation\n\n//MARK: U"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Value.swift",
    "chars": 972,
    "preview": "//\n//  SwifQLable+Value.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 27.01.2020.\n//\n\nimport Foundation\n\nextension "
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Values.swift",
    "chars": 2250,
    "preview": "//\n//  SwifQLable+Values.swift\n//  App\n//\n//  Created by Mihael Isaev on 25/11/2018.\n//\n\nimport Foundation\n\nextension Sw"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Where.swift",
    "chars": 640,
    "preview": "//\n//  SwifQLable+Where.swift\n//  SwifQLCore\n//\n//  Created by Mihael Isaev on 13/11/2018.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+WhereExists.swift",
    "chars": 608,
    "preview": "//\n//  SwifQLable+WhereExists.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 23/07/2019.\n//\n\nimport Foundation\n\n//MA"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+WhereNotExists.swift",
    "chars": 680,
    "preview": "//\n//  SwifQLable+WhereNotExists.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 23/07/2019.\n//\n\nimport Foundation\n\n/"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+Window.swift",
    "chars": 1772,
    "preview": "//\n//  SwifQLable+Window.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 22.05.2020.\n//\n\nimport Foundation\n\n//MARK: W"
  },
  {
    "path": "Sources/SwifQL/SwifQLable+Parts/SwifQLable+With.swift",
    "chars": 1535,
    "preview": "//\n//  SwifQLable+Timestamp.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 02/08/2019.\n//\n\nimport Foundation\n\n//MARK"
  },
  {
    "path": "Sources/SwifQL/SwifQLable.swift",
    "chars": 3915,
    "preview": "//\n//  SwifQLable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 04/11/2018.\n//\n\nimport Foundation\n\npublic protocol "
  },
  {
    "path": "Sources/SwifQL/SwifQLableArraySeparator.swift",
    "chars": 287,
    "preview": "//\n//  SwifQLableArraySeparator.swift\n//  \n//\n//  Created by Mihael Isaev on 26.01.2020.\n//\n\nimport Foundation\n\npublic e"
  },
  {
    "path": "Sources/SwifQL/Table.swift",
    "chars": 6028,
    "preview": "//\n//  Tableable.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 05/11/2018.\n//\n\nimport Foundation\n\npublic protocol A"
  },
  {
    "path": "Sources/SwifQL/TableAlias.swift",
    "chars": 3934,
    "preview": "//\n//  TableAlias.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 11/11/2018.\n//\n\nimport Foundation\n\n\n/// Create alia"
  },
  {
    "path": "Sources/SwifQL/Type+Autodetect.swift",
    "chars": 6204,
    "preview": "//\n//  Type+Autodetect.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\nimport Foundation\n\nextension T"
  },
  {
    "path": "Sources/SwifQL/Type+SwifQLable.swift",
    "chars": 2672,
    "preview": "//\n//  SwifQLable+Types.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 04/11/2018.\n//\n\nimport Foundation\n\nextension "
  },
  {
    "path": "Sources/SwifQL/Type.swift",
    "chars": 18972,
    "preview": "//\n//  Type.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 12/10/2019.\n//\n\ntypealias CastType = Type\n\npublic struct "
  },
  {
    "path": "Sources/SwifQL/_Todo.swift",
    "chars": 283,
    "preview": "//\n//  Todo.swift\n//  SwifQL\n//\n//  Created by Mihael Isaev on 29.01.2020.\n//\n\n// MARK: - Improve drop table\n// https://"
  },
  {
    "path": "Tests/SwifQLTests/BuilderTests.swift",
    "chars": 1952,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Builder Tests\")\nstruct BuilderTests: SwifQLTests {\n    @Te"
  },
  {
    "path": "Tests/SwifQLTests/CaseTests.swift",
    "chars": 1422,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Case Tests\")\nstruct CaseTests: SwifQLTests {\n    // MARK: "
  },
  {
    "path": "Tests/SwifQLTests/DirectiveTests.swift",
    "chars": 5690,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Directive Tests\")\nstruct DirectiveTests: SwifQLTests {\n   "
  },
  {
    "path": "Tests/SwifQLTests/ExistsTests.swift",
    "chars": 1032,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Exists Tests\")\nstruct ExistsTests: SwifQLTests {\n    //MAR"
  },
  {
    "path": "Tests/SwifQLTests/FnTests.swift",
    "chars": 5168,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Fn Tests\")\nstruct FnTests: SwifQLTests {\n    // MARK: - Fn"
  },
  {
    "path": "Tests/SwifQLTests/FromTests.swift",
    "chars": 1765,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"From Tests\")\nstruct FromTests: SwifQLTests {\n    //MARK: -"
  },
  {
    "path": "Tests/SwifQLTests/JsonTests.swift",
    "chars": 1987,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Json Tests\")\nstruct JsonTests: SwifQLTests {\n    // MARK: "
  },
  {
    "path": "Tests/SwifQLTests/OrderTests.swift",
    "chars": 1944,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Order Tests\")\nstruct OrderTests: SwifQLTests {\n    // MARK"
  },
  {
    "path": "Tests/SwifQLTests/OtherTests.swift",
    "chars": 15361,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Other Tests\")\nstruct OtherTests: SwifQLTests {\n    // MARK"
  },
  {
    "path": "Tests/SwifQLTests/PredicateTest.swift",
    "chars": 8154,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Predicate Tests\")\nstruct PredicateTests: SwifQLTests {\n   "
  },
  {
    "path": "Tests/SwifQLTests/SelectTests.swift",
    "chars": 17024,
    "preview": "@testable import SwifQL\nimport Testing\nimport Foundation\n\n@Suite(\"Select Tests\")\nstruct SelectTests: SwifQLTests {\n    @"
  },
  {
    "path": "Tests/SwifQLTests/SubqueryTests.swift",
    "chars": 1781,
    "preview": "@testable import SwifQL\nimport Testing\nimport XCTest\n\n@Suite(\"Subquery Tests\")\nstruct SubqueryTests: SwifQLTests {\n    /"
  },
  {
    "path": "Tests/SwifQLTests/SwifQLTestCase.swift",
    "chars": 2254,
    "preview": "import XCTest\n@testable import SwifQL\n\nprotocol SwifQLTests {}\nextension SwifQLTests {\n    func check(_ query: SwifQLabl"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the MihaelIsaev/SwifQL GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 202 files (443.7 KB), approximately 123.1k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!