Lighter-swift / Lighter

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.

Home Page:https://lighter-swift.github.io/documentation/lighter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated comment incorrectly claims "has default"

helje5 opened this issue · comments

When generating code for this SQL:

CREATE TABLE Talents (
    id   UUID PRIMARY KEY NOT NULL,
    name TEXT NOT NULL
);

The DocC comment for the records is this (notice the "has default"):

public struct Talents : Identifiable, SQLKeyedTableRecord, Codable {
  
  /// Static SQL type information for the ``Talents`` record.
  public static let schema = Schema()
  
  /// Primary key `id` (`UUID`), required (has default).
  public var id : UUID
  
  /// Column `name` (`TEXT`), required (has default).
  public var name : String
}

Neither id nor name has a database default though:

sqlite> PRAGMA table_info(Talents);
cid  name  type  notnull  dflt_value  pk
---  ----  ----  -------  ----------  --
0    id    UUID  1                    1 
1    name  TEXT  1                    0 

Though they get default values assigned in Swift:

    public let id = MappedColumn<Talents, UUID>(
      externalName: "id",
      defaultValue: UUID(uuid: ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )),
      keyPath: \Talents.id
    )
    public let name = MappedColumn<Talents, String>(
      externalName: "name",
      defaultValue: "",
      keyPath: \Talents.name
    )

Fixed.