Skip to content

Commit 90a67ad

Browse files
committed
Ignore if it cannot find the queries folder
1 parent fe298d6 commit 90a67ad

4 files changed

Lines changed: 28 additions & 35 deletions

File tree

Example/Todo.xcodeproj/project.pbxproj

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
DE3F3E572E5FBE8100F4A251 /* Otter in Frameworks */ = {isa = PBXBuildFile; productRef = DE3F3E562E5FBE8100F4A251 /* Otter */; };
10+
DE3F47E12E64A90B00F4A251 /* Otter in Frameworks */ = {isa = PBXBuildFile; productRef = DE3F47E02E64A90B00F4A251 /* Otter */; };
1111
/* End PBXBuildFile section */
1212

1313
/* Begin PBXContainerItemProxy section */
@@ -43,7 +43,7 @@
4343
isa = PBXFrameworksBuildPhase;
4444
buildActionMask = 2147483647;
4545
files = (
46-
DE3F3E572E5FBE8100F4A251 /* Otter in Frameworks */,
46+
DE3F47E12E64A90B00F4A251 /* Otter in Frameworks */,
4747
);
4848
runOnlyForDeploymentPostprocessing = 0;
4949
};
@@ -89,14 +89,14 @@
8989
buildRules = (
9090
);
9191
dependencies = (
92-
DE3F3E592E5FBEA000F4A251 /* PBXTargetDependency */,
92+
DE5433DF2E64A9D400736214 /* PBXTargetDependency */,
9393
);
9494
fileSystemSynchronizedGroups = (
9595
DE3F3E2D2E5FBE5800F4A251 /* Todo */,
9696
);
9797
name = Todo;
9898
packageProductDependencies = (
99-
DE3F3E562E5FBE8100F4A251 /* Otter */,
99+
DE3F47E02E64A90B00F4A251 /* Otter */,
100100
);
101101
productName = Todo;
102102
productReference = DE3F3E2B2E5FBE5800F4A251 /* Todo.app */;
@@ -154,7 +154,7 @@
154154
mainGroup = DE3F3E222E5FBE5800F4A251;
155155
minimizedProjectReferenceProxies = 1;
156156
packageReferences = (
157-
DE3F3E552E5FBE8000F4A251 /* XCRemoteSwiftPackageReference "Otter" */,
157+
DE3F47DF2E64A90B00F4A251 /* XCLocalSwiftPackageReference "../../Otter" */,
158158
);
159159
preferredProjectObjectVersion = 77;
160160
productRefGroup = DE3F3E2C2E5FBE5800F4A251 /* Products */;
@@ -207,9 +207,9 @@
207207
target = DE3F3E2A2E5FBE5800F4A251 /* Todo */;
208208
targetProxy = DE3F3E392E5FBE5900F4A251 /* PBXContainerItemProxy */;
209209
};
210-
DE3F3E592E5FBEA000F4A251 /* PBXTargetDependency */ = {
210+
DE5433DF2E64A9D400736214 /* PBXTargetDependency */ = {
211211
isa = PBXTargetDependency;
212-
productRef = DE3F3E582E5FBEA000F4A251 /* OtterPlugin */;
212+
productRef = DE5433DE2E64A9D400736214 /* OtterPlugin */;
213213
};
214214
/* End PBXTargetDependency section */
215215

@@ -461,26 +461,21 @@
461461
};
462462
/* End XCConfigurationList section */
463463

464-
/* Begin XCRemoteSwiftPackageReference section */
465-
DE3F3E552E5FBE8000F4A251 /* XCRemoteSwiftPackageReference "Otter" */ = {
466-
isa = XCRemoteSwiftPackageReference;
467-
repositoryURL = "https://github.com/wickwirew/Otter";
468-
requirement = {
469-
branch = main;
470-
kind = branch;
471-
};
464+
/* Begin XCLocalSwiftPackageReference section */
465+
DE3F47DF2E64A90B00F4A251 /* XCLocalSwiftPackageReference "../../Otter" */ = {
466+
isa = XCLocalSwiftPackageReference;
467+
relativePath = ../../Otter;
472468
};
473-
/* End XCRemoteSwiftPackageReference section */
469+
/* End XCLocalSwiftPackageReference section */
474470

475471
/* Begin XCSwiftPackageProductDependency section */
476-
DE3F3E562E5FBE8100F4A251 /* Otter */ = {
472+
DE3F47E02E64A90B00F4A251 /* Otter */ = {
477473
isa = XCSwiftPackageProductDependency;
478-
package = DE3F3E552E5FBE8000F4A251 /* XCRemoteSwiftPackageReference "Otter" */;
479474
productName = Otter;
480475
};
481-
DE3F3E582E5FBEA000F4A251 /* OtterPlugin */ = {
476+
DE5433DE2E64A9D400736214 /* OtterPlugin */ = {
482477
isa = XCSwiftPackageProductDependency;
483-
package = DE3F3E552E5FBE8000F4A251 /* XCRemoteSwiftPackageReference "Otter" */;
478+
package = DE3F47DF2E64A90B00F4A251 /* XCLocalSwiftPackageReference "../../Otter" */;
484479
productName = "plugin:OtterPlugin";
485480
};
486481
/* End XCSwiftPackageProductDependency section */

Example/Todo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Otter can even run within a Swift macro by adding the `@Database` macro to a `st
7878
```swift
7979
@Database
8080
struct DB {
81-
@Query("SELECT * FROM foo")
82-
var selectFoo: any SelectFooQuery
81+
@Query("SELECT * FROM todo")
82+
var selectTodos: any SelectTodosQuery
8383

8484
static var migrations: [String] {
8585
return [
@@ -108,7 +108,7 @@ func main() async throws {
108108
> As of now it is not recommended for larger projects. There are quite a few limitations
109109
that won't scale well beyond a fairly simple schema and a handful of queries.
110110

111-
#### Anatomy of a @Query
111+
#### Anatomy of @Query
112112
```swift
113113
@Query(
114114
"SELECT * FROM foo WHERE id IN ?", // 1.
@@ -148,7 +148,7 @@ let package = Package(
148148
.target(
149149
name: "MyProject",
150150
dependencies: ["Otter"],
151-
// ⚠️ Plugin is optional, can just use the CLI if desired
151+
// ⚠️ Plugin is optional but suggested. Can just use the CLI if desired
152152
plugins: [.plugin(name: "OtterPlugin", package: "Otter")]
153153
),
154154
]

Sources/Compiler/Driver.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ public actor Driver {
5252
public func compile(migrationsPath: Path, queriesPath: Path) async throws {
5353
try await measure("Compilation") {
5454
let migrationFiles = try fileSystem.files(atPath: migrationsPath)
55-
let queriesFiles = try fileSystem.files(atPath: queriesPath)
55+
56+
// Don't error out if it cannot find the queries. Most people will likely
57+
// create the migrations and try to build to see if things work before
58+
// they create their first query. If it can find the migrations folder
59+
// thats probably good enough.
60+
let queriesFiles = try fileSystem.exists(at: queriesPath)
61+
? try fileSystem.files(atPath: queriesPath)
62+
: []
5663

5764
// Migrations must be run synchronously in order.
5865
for migration in try sortMigrations(fileNames: migrationFiles) {

0 commit comments

Comments
 (0)