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

fix(LiteralValue): 'LiteralValue' initializer is inaccessible due to 'internal' protection #1223

Open
theonetheycallneo opened this issue Sep 8, 2023 · 0 comments

Comments

@theonetheycallneo
Copy link

Issues are used to track bugs and feature requests.
Need help or have a general question? Ask on Stack Overflow (tag sqlite.swift).

Build Information

  • Include the SQLite.swift version, commit or branch experiencing the issue.
    .package(url: "https://github.com/stephencelis/SQLite.swift", from: "0.14.1"),
  • Mention Xcode and OS X versions affected.
    platforms: [.macOS(.v12)]
  • How do do you integrate SQLite.swift in your project?
    Swift Package manager

General guidelines

  • Be as descriptive as possible.

Creating dynamic columns in tables needs a way to create defaultValues:

public struct TableSchema: Codable, Equatable {
  public let schema: String
  public let name: String
  public let strict: Int
  public let num_cols: Int
  public let without_row_id: Int
  public let columns: [String: ColumnSchema]

  public func convertDataType(_ dataType: String) -> ColumnDefinition.Affinity {
    switch dataType {
      case "INTEGER":
        return ColumnDefinition.Affinity.INTEGER
      case "REAL":
        return ColumnDefinition.Affinity.REAL
      case "TEXT":
        return ColumnDefinition.Affinity.TEXT
      case "BLOB":
        return ColumnDefinition.Affinity.BLOB
      default:
        return ColumnDefinition.Affinity.TEXT
    }
  }
  
  public func createTable(in db: Connection) throws {
    let table = Table(self.name)
    try db.run(table.create(ifNotExists: true, block: { t in
        for column in columns {
            let col = column.value
            let columnDefinition = ColumnDefinition(
              name: col.name,
              type: convertDataType(col.data_type),
              nullable: col.nullable == 1,
              defaultValue: LiteralValue.init(col.default_value ?? "NULL") 
            )
            
            t.column(columnDefinition)
        }
    }))
  }
}

  • Provide as much information needed to reliably reproduce the issue.
  • Attach screenshots if possible.
  • Better yet: attach GIFs or link to video.
  • Even better: link to a sample project exhibiting the issue.

public enum LiteralValue should have public init

init(_ string: String?) {
        guard let string = string else {
            self = .NULL
            return
        }
        switch string {
        case "NULL": self = .NULL
        case "TRUE": self = .TRUE
        case "FALSE": self = .FALSE
        case "CURRENT_TIME": self = .CURRENT_TIME
        case "CURRENT_TIMESTAMP": self = .CURRENT_TIMESTAMP
        case "CURRENT_DATE": self = .CURRENT_DATE
        default: self = LiteralValue.parse(string)
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant