Expression<Int64> is broken

Open
#1,311 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
sqlite, swift
Domain
databases

Research direction

Start with Expression.swift around line 110 and reproduce the reported behavior under Xcode 16.2 using Expression(value: "id") and the t.column example. Compare the resulting SQLite schema and expression type with the expected INTEGER and Expression; done means the examples compile and produce the stated types and schema.

Written by the indexing model from the issue text.

Description

Running v0.15.3 under Xcode 16.2

Under Usage:
let id = Expression("id")

t.column(id, primaryKey: true)

is suppose to translate to the query clause
"id" INTEGER PRIMARY KEY NOT NULL
Instead it is translated to
"id" TEXT PRIMARY KEY NOT NULL

Note: Under Xcode 16, it now necessary to include the argument label 'value.
let id = Expression(value: "id")

After executions id is
id SQLite.Expression
when it should be
id SQLite.Expression

The problem is the code base takes its UnderlyingType from "id", which is a String,
not from . See Expression.swift, line 110.

The fact Expression is translated to TEXT is further exemplified by
the following code which will no longer compile:

enum booleans: Int64 {
case TRUE = 1, FALSE = 0
}
let isActive = Expression(value: "isActive")

t.column(isActive, defaultValue: booleans.TRUE.rawValue)

results in the compiler error:

Cannot convert value of type 'Expression' to expected argument type 'Expression<Int64?>'

Dominant language
Swift
Stars
10.2k
Forks
1.6k
Avg merge
6d 2h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stephencelis/SQLite.swift

All issues in stephencelis/SQLite.swift

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.