Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Sep 19, 2024
2 parents d5731a1 + 26c9bc0 commit bf5b78c
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 65 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
fail-fast: false
matrix:
image:
- swift:5.3.2-xenial
- swift:5.5.0-focal
- swift:5.6.1-bionic
- swift:5.9.2-focal
- swift:5.10-jammy
- swift:6.0-noble
container: ${{ matrix.image }}
steps:
- name: Install SQLite
run: |
apt-get update
apt-get -y install libsqlite3-dev
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build Swift Debug Package
run: swift build -c debug
- name: Build Swift Release Package
Expand All @@ -34,11 +34,11 @@ jobs:
runs-on: macos-latest
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1.2.1
uses: maxim-lobanov/setup-xcode@v1.5.1
with:
xcode-version: 13.2.1
xcode-version: latest
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build Xcode Project
run: xcodebuild -project ZeeQL3.xcodeproj -scheme ZeeQL
- name: Build Swift Debug Package
Expand Down
6 changes: 3 additions & 3 deletions Sources/ZeeQL/Access/Codable/CodableModelEntityDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ extension CodableModelDecoder {

// MARK: - SingleContainer

private struct SingleContainer<EntityType: Decodable>
private struct SingleContainer<E: Decodable>
: SingleValueDecodingContainer
{
let log : ZeeQLLogger
let decoder : CodableModelEntityDecoder<EntityType>
let decoder : CodableModelEntityDecoder<E>
var codingPath : [ CodingKey ] { return decoder.codingPath }

init(decoder: CodableModelEntityDecoder<EntityType>) {
init(decoder: CodableModelEntityDecoder<E>) {
self.decoder = decoder
self.log = decoder.log
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ZeeQL/Access/DatabaseChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1145,9 +1145,9 @@ open class TypedDatabaseChannel<ObjectType: DatabaseObject> : DatabaseChannelBas
return ObjectType.self
}

func fetchObject<ObjectType>() -> ObjectType? {
func fetchObject<O>() -> O? {
guard let o = super.fetchObject() else { return nil }
guard let to = o as? ObjectType else {
guard let to = o as? O else {
// throw something
log.warn("fetchObject returned an unexpected type:", o, type(of: o))
return nil
Expand Down
2 changes: 2 additions & 0 deletions Sources/ZeeQL/Access/SchemaGeneration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public protocol SchemaGeneration: AnyObject {
* FOREIGN KEY ( target_id ) REFERENCES target( target_id );
* ALTER TABLE table DROP CONSTRAINT table2target;
* - Note: constraint name must be known!
*
* SQLite doesn't support this (2023-09-06).
*/
var supportsDirectForeignKeyModification : Bool { get }
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/ZeeQL/SQLite3Adaptor/SQLite3ModelFetch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ZeeQL3
//
// Created by Helge Hess on 14/04/17.
// Copyright © 2017-2019 ZeeZide GmbH. All rights reserved.
// Copyright © 2017-2021 ZeeZide GmbH. All rights reserved.
//

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ open class SQLite3ModelFetch: AdaptorModelFetch {
public func describeDatabaseNames(like: String?) throws -> [String] {
// TBD: what about the _like? Which syntax is expected?
var dbNames = [ String ]()
try channel.querySQL("pragma database_list") { record in
try channel.querySQL("PRAGMA database_list") { record in
if let name = record["name"] as? String, name != "temp" {
dbNames.append(name)
}
Expand Down Expand Up @@ -89,14 +89,14 @@ open class SQLite3ModelFetch: AdaptorModelFetch {
func _fetchColumnsOfTable(_ table: String) throws -> [ AdaptorRecord ] {
// keys: cid, name, type, notnull, dflt_value, pk
let records : [ AdaptorRecord ] =
try channel.querySQL("pragma table_info(\(table))")
try channel.querySQL("PRAGMA table_info(\(table))")
return records
}

func _fetchForeignKeysOfTable(_ table: String) throws -> [ AdaptorRecord ] {
// keys: id, seq, table, from, to, on_update, on_delete, match
let records : [ AdaptorRecord ] =
try channel.querySQL("pragma foreign_key_list(\(table))")
try channel.querySQL("PRAGMA foreign_key_list(\(table))")
return records
}

Expand Down
54 changes: 27 additions & 27 deletions Tests/ZeeQLTests/SQLite3CodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {

/* Containers */

internal final class KeyedContainer<T: Decodable, Key: CodingKey>
internal final class KeyedContainer<D: Decodable, Key: CodingKey>
: KeyedDecodingContainerProtocol
{
let decoder : AdaptorRecordDecoder<T>
let decoder : AdaptorRecordDecoder<D>
let log : ZeeQLLogger

let codingPath : [ CodingKey ]
let allKeys : [ Key ]

init(decoder: AdaptorRecordDecoder<T>) {
init(decoder: AdaptorRecordDecoder<D>) {
self.decoder = decoder
self.log = decoder.log
self.codingPath = decoder.codingPath
Expand Down Expand Up @@ -275,8 +275,8 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
* - base types column arrays, like `[Int]`,
* - arrays of CodableObjectType`s aka relationships
*/
func decode<T>(_ type: T.Type, forKey key: Key) throws -> T
where T : Decodable
func decode<X>(_ type: X.Type, forKey key: Key) throws -> X
where X : Decodable
{
switch type {
case is RelationshipHolderType.Type:
Expand Down Expand Up @@ -331,9 +331,9 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
}

private
func decodeImplicitRelationshipHolder<T>(_ type: T.Type, forKey key: Key)
throws -> T
where T : Decodable
func decodeImplicitRelationshipHolder<X>(_ type: X.Type, forKey key: Key)
throws -> X
where X : Decodable
{
// Right now this is an Array, eg `var addresses : [ Address ]`.
// We just want to return an empty array here.
Expand All @@ -346,8 +346,8 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
return v
}

func decodeOtherType<T>(_ type: T.Type, forKey key: Key) throws -> T
where T : Decodable
func decodeOtherType<X>(_ type: X.Type, forKey key: Key) throws -> X
where X : Decodable
{
log.trace("out of band type:", type, "for key:", key)

Expand All @@ -358,10 +358,10 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
/**
* Decode base type column arrays, like `[ Int ]`
*/
func decodeBaseTypeArray<T, E>(_ type: T.Type,
func decodeBaseTypeArray<X, E>(_ type: X.Type,
_ elementType: E.Type,
forKey key: Key) throws -> T
where T : Decodable
forKey key: Key) throws -> X
where X : Decodable
{
log.error("TODO: Array<Int>")
throw Error.unsupportedValueType(type)
Expand All @@ -376,9 +376,9 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
* while the other was reflected on.
*/
private
func decodeRelationshipHolder<T>(erasedHolderType : T.Type,
forKey key : Key) throws -> T
where T : Decodable
func decodeRelationshipHolder<X>(erasedHolderType : X.Type,
forKey key : Key) throws -> X
where X : Decodable
{
guard let reflectedHolderType =
erasedHolderType as? RelationshipHolderType.Type
Expand All @@ -402,9 +402,9 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
*
* This is not actually supported in the AdaptorDecoder.
*/
private func decodeDecodableObject<T>(_ type: T.Type,
forKey key: Key) throws -> T
where T : Decodable
private func decodeDecodableObject<X>(_ type: X.Type,
forKey key: Key) throws -> X
where X : Decodable
{
log.trace(":decode:", key.stringValue, type)
throw Error.unsupportedValueType(type) // FIXME: proper error
Expand Down Expand Up @@ -445,14 +445,14 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
log.trace("decoded-value for key:", key, anyValue)
return anyValue
}
func decodeBaseType<T>(forKey key: Key) throws -> T {
func decodeBaseType<X>(forKey key: Key) throws -> X {
let anyValue = try valueForKey(key)
guard let v = anyValue as? T else {
guard let v = anyValue as? X else {
log.error("unexpected base value:", key,
"\n value:", anyValue,
"\n types:",
type(of: anyValue), "vs", T.self, "\n")
throw Error.unsupportedValueType(T.self)
type(of: anyValue), "vs", X.self, "\n")
throw Error.unsupportedValueType(X.self)
}
log.trace("decoded-key:", key, v)
return v
Expand Down Expand Up @@ -542,11 +542,11 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
* var addresses : [ Address ]
*
*/
internal struct UnkeyedContainer<T: Decodable> : UnkeyedDecodingContainer {
internal struct UnkeyedContainer<D: Decodable> : UnkeyedDecodingContainer {
// TBD: is this also for `[ Int ]` and such? (I think we want to capture
// those earlier as `[Int]`, `[Float]` etc).
let log : ZeeQLLogger
let decoder : AdaptorRecordDecoder<T>
let decoder : AdaptorRecordDecoder<D>

let sourceKey : CodingKey

Expand All @@ -556,7 +556,7 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {

var count : Int? { return 0 } // no need to decode anything!

init(decoder : AdaptorRecordDecoder<T>, key : CodingKey) {
init(decoder : AdaptorRecordDecoder<D>, key : CodingKey) {
self.decoder = decoder
self.log = decoder.log
self.sourceKey = key
Expand All @@ -571,7 +571,7 @@ public class AdaptorRecordDecoder<T: Decodable> : Decoder {
*
* We create our ToMany relationship in here.
*/
mutating func decode<T>(_ type: T.Type) throws -> T where T : Decodable {
mutating func decode<X>(_ type: X.Type) throws -> X where X : Decodable {
log.trace("decode index:", currentIndex, type, "source-key:", sourceKey)
throw Error.adaptorCannotDecodeRelationships
}
Expand Down
46 changes: 36 additions & 10 deletions ZeeQL3.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -1084,8 +1084,9 @@
E8D2794B1E5504FA00453BBE /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1100;
LastUpgradeCheck = 1330;
LastUpgradeCheck = 1600;
ORGANIZATIONNAME = "ZeeZide GmbH";
TargetAttributes = {
E8263C541E93B1E100508276 = {
Expand Down Expand Up @@ -1630,7 +1631,11 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Tests/ZeeQLTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = de.zeezide.ZeeQL.SQLite3Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
Expand Down Expand Up @@ -1666,7 +1671,11 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Tests/ZeeQLTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = de.zeezide.ZeeQL.SQLite3Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -1684,7 +1693,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
Expand All @@ -1706,7 +1720,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -1719,7 +1738,6 @@
E8263C811E93C7DF00508276 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1748,7 +1766,12 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Tests/ZeeQLTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-DZEE_BUNDLE_RESOURCES";
PRODUCT_BUNDLE_IDENTIFIER = de.zeezide.ZeeQL.MobileZeeQLTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1761,7 +1784,6 @@
E8263C821E93C7DF00508276 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1790,7 +1812,11 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Tests/ZeeQLTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-DZEE_BUNDLE_RESOURCES";
PRODUCT_BUNDLE_IDENTIFIER = de.zeezide.ZeeQL.MobileZeeQLTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion ZeeQL3.xcodeproj/xcshareddata/xcschemes/ZeeQL.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit bf5b78c

Please sign in to comment.