Skip to content

Commit b78ba2c

Browse files
committed
Fix Northwind.swift links
And update pkg versions to latest.
1 parent 86088b7 commit b78ba2c

File tree

8 files changed

+86
-11
lines changed

8 files changed

+86
-11
lines changed

AppLogic/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let package = Package(
1616
dependencies: [
1717
.package(url: "https://github.com/Lighter-swift/Lighter.git",
1818
from: "1.0.24"),
19-
.package(url: "https://github.com/Lighter-swift/NorthwindSQLite.swift.git",
19+
.package(url: "https://github.com/Northwind-swift/NorthwindSQLite.swift.git",
2020
from: "1.0.12"),
2121

2222
.package(url: "https://github.com/Macro-swift/MacroExpress.git",

LighterExamples.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
E81B195A28A0782D003A0F1C /* SupplierForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupplierForm.swift; sourceTree = "<group>"; };
5959
E81B195C28A07836003A0F1C /* CategoryInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryInfo.swift; sourceTree = "<group>"; };
6060
E81B195E28A078B8003A0F1C /* Picture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Picture.swift; sourceTree = "<group>"; };
61+
E81D692B28CCCA5D004F5E26 /* Lighter */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Lighter; path = ../Lighter; sourceTree = "<group>"; };
6162
E8224F9D28A0060F00246A1F /* AppLogic */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = AppLogic; sourceTree = "<group>"; };
6263
E8224FA328A0063A00246A1F /* NorthwindWebAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NorthwindWebAPI; sourceTree = BUILT_PRODUCTS_DIR; };
6364
E8224FAB28A0065C00246A1F /* Products.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Products.swift; sourceTree = "<group>"; };
@@ -75,7 +76,7 @@
7576
E8224FC928A0071100246A1F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7677
E8224FCB28A0071100246A1F /* NorthwindSwiftUI.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NorthwindSwiftUI.entitlements; sourceTree = "<group>"; };
7778
E8224FCD28A0071100246A1F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
78-
E8224FD328A0073000246A1F /* NorthwindApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NorthwindApp.swift; sourceTree = "<group>"; };
79+
E8224FD328A0073000246A1F /* NorthwindApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = NorthwindApp.swift; sourceTree = "<group>"; };
7980
E8224FD428A0073000246A1F /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
8081
E8224FDB28A0557000246A1F /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
8182
E8224FDC28A0557000246A1F /* CONTRIBUTING.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
@@ -128,6 +129,7 @@
128129
E8224F8228A005CF00246A1F = {
129130
isa = PBXGroup;
130131
children = (
132+
E81D692B28CCCA5D004F5E26 /* Lighter */,
131133
E8224FDB28A0557000246A1F /* README.md */,
132134
E8224FDD28A0557000246A1F /* LICENSE */,
133135
E8224FDC28A0557000246A1F /* CONTRIBUTING.md */,

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ var package = Package(
1111
],
1212

1313
dependencies: [
14-
.package(url: "https://github.com/Lighter-swift/Lighter.git", from: "1.0.24"),
15-
.package(url: "https://github.com/Lighter-swift/NorthwindSQLite.swift.git",
16-
from: "1.0.10"),
14+
.package(url: "https://github.com/Lighter-swift/Lighter.git", from: "1.0.30"),
15+
.package(url: "https://github.com/Northwind-swift/NorthwindSQLite.swift.git",
16+
from: "1.0.14"),
1717

1818
.package(url: "https://github.com/Macro-swift/MacroExpress.git",
1919
from: "1.0.2"),

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Examples for the Lighter SQLite environment, SwiftUI and server side.
88
Note: The examples require Swift 5.7 / Xcode 14b for proper plugin support.
99

1010
When embedding a package using Enlighter (like
11-
[NorthwindSQLite.swift](https://github.com/Lighter-swift/NorthwindSQLite.swift.git)),
11+
[NorthwindSQLite.swift](https://github.com/Northwind-swift/NorthwindSQLite.swift.git)),
1212
[a local package](https://developer.apple.com/documentation/xcode/organizing-your-code-with-local-packages)
1313
seems to be required w/ the Xcode 14 beta (3...5).
1414
Otherwise the Swift package plugins do not seem to run.
@@ -22,7 +22,7 @@ help.
2222
The Northwind database is a common database example that has been ported
2323
to SQLite.
2424
Lighter provides a Swift version of that in the
25-
[NorthwindSQLite.swift](https://github.com/Lighter-swift/NorthwindSQLite.swift)
25+
[NorthwindSQLite.swift](https://github.com/Northwind-swift/NorthwindSQLite.swift)
2626
repository.
2727

2828
> Note: The particular SQLite version of the Northwind database is quite
@@ -31,7 +31,7 @@ repository.
3131
> That actually makes it a good example on how to deal with such databases in
3232
> Lighter.
3333
34-
The Swift Northwind API: [Documentation](https://Lighter-swift.github.io/NorthwindSQLite.swift/documentation/northwind/).
34+
The Swift Northwind API: [Documentation](https://Northwind-swift.github.io/NorthwindSQLite.swift/documentation/northwind/).
3535

3636

3737
### Examples

Sources/NorthwindSwiftUI/NorthwindApp.swift

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22
import Northwind
33
import Lighter
4+
import SQLite3
45

56
/// Global application state. A good place to setup the database object.
67
@main
@@ -9,6 +10,78 @@ struct NorthwindApp: App {
910
let database = (try? Northwind.bootstrap(
1011
copying: Northwind.module.connectionHandler.url
1112
)) ?? .module!
13+
14+
init() {
15+
lowlevelTests()
16+
if #available(iOS 16, *) {
17+
try! regexTests()
18+
}
19+
}
20+
21+
@available(iOS 16, *)
22+
private func regexTests() throws {
23+
// https://unicode-org.github.io/icu/userguide/strings/regexp.html
24+
let products = try database.products.filter {
25+
$0.productName.wholeMatch(of: /^\w+\s+\w+$/) != nil
26+
}
27+
print("Products:", products.map(\.productName))
28+
}
29+
30+
private func lowlevelTests() {
31+
let url = database.connectionHandler.url
32+
var db : OpaquePointer?
33+
let rc = sqlite3_open_v2(
34+
url.absoluteString, &db,
35+
SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, nil
36+
)
37+
assert(rc == SQLITE_OK)
38+
defer {
39+
sqlite3_close(db)
40+
}
41+
42+
let _/* allProducts*/ = sqlite3_products_fetch(db)
43+
44+
guard let products = sqlite3_products_fetch(
45+
db, sql:
46+
"""
47+
SELECT ProductId, ProductName, QuantityPerUnit FROM Products
48+
WHERE QuantityPerUnit LIKE '%boxes%'
49+
""",
50+
filter: { _ in true }
51+
) else {
52+
let error = SQLError(db)
53+
fatalError("FETCH FAILED: \(error)")
54+
}
55+
print("Products: #\(products.count)")
56+
// products.first?.discontinued
57+
58+
var statement : OpaquePointer?
59+
let rc2 = sqlite3_prepare_v2(
60+
db,
61+
"""
62+
SELECT ProductId, ProductName, QuantityPerUnit FROM Products
63+
WHERE QuantityPerUnit LIKE ?
64+
""",
65+
-1, &statement, nil
66+
)
67+
assert(rc2 == SQLITE_OK)
68+
defer { sqlite3_finalize(statement) }
69+
70+
let SQLITE_TRANSIENT = unsafeBitCast(-1, to: sqlite3_destructor_type?.self)
71+
72+
sqlite3_bind_text(statement, 1, "%boxes%", -1, SQLITE_TRANSIENT)
73+
74+
//let indices = Product.Schema.lookupColumnIndices(in: statement)
75+
var records = [ ( id: Int, name: String ) ]()
76+
while sqlite3_step(statement) == SQLITE_ROW {
77+
let product = Product(statement)
78+
//let product = Product(statement, indices: indices)
79+
records.append( ( id: product.id, name: product.productName ) )
80+
}
81+
print("RECORDS: #\(records.count)")
82+
83+
// Abuse it by renaming :-)
84+
}
1285

1386
var body: some Scene {
1487
WindowGroup {

Sources/NorthwindSwiftUI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ but keeps everything in local states.
1414

1515
Note: The example requires Swift 5.7 / Xcode 14b for proper plugin support.
1616

17-
Northwind API: [Documentation](https://55db091a-8471-447b-8f50-5dff4c1b14ac.github.io/NorthwindSQLite.swift/documentation/northwind/)
17+
Northwind API: [Documentation](https://Northwind-sqlite.github.io/NorthwindSQLite.swift/documentation/northwind/)
1818

1919

2020

Sources/NorthwindWebAPI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The example in a nutshell:
4646
```swift
4747
#!/usr/bin/swift sh
4848
import MacroExpress // @Macro-swift
49-
import Northwind // @Lighter-swift/NorthwindSQLite.swift
49+
import Northwind // @Northwind-swift/NorthwindSQLite.swift
5050

5151
// Get a handle to the database
5252
let db = Northwind.module!

Sources/NorthwindWebAPI/views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h2 class="ui header">Server Setup</h2>
5151
<pre><code class="language-swift"
5252
>#!/usr/bin/swift sh
5353
import MacroExpress // @Macro-swift
54-
import Northwind // @Lighter-swift/NorthwindSQLite.swift
54+
import Northwind // @Northwind-swift/NorthwindSQLite.swift
5555

5656
let db = Northwind.module!
5757
let app = express()

0 commit comments

Comments
 (0)