Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated comment incorrectly claims "has default" #13

Closed
helje5 opened this issue Aug 24, 2022 · 1 comment
Closed

Generated comment incorrectly claims "has default" #13

helje5 opened this issue Aug 24, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@helje5
Copy link
Member

helje5 commented Aug 24, 2022

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
    )
@helje5 helje5 added the bug Something isn't working label Aug 24, 2022
@helje5 helje5 self-assigned this Aug 24, 2022
helje5 added a commit that referenced this issue Aug 24, 2022
If no default value is set, the comment won't be generated.
Also improved the string comment a little.
@helje5
Copy link
Member Author

helje5 commented Aug 24, 2022

Fixed.

@helje5 helje5 closed this as completed Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant