Skip to content

Commit

Permalink
Fix a compile warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Jun 28, 2020
1 parent 5b6f7ed commit f8f301d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
<attribute name="tag" optional="YES" attributeType="String"/>
<attribute name="text" optional="YES" attributeType="String"/>
<attribute name="title" optional="YES" attributeType="String"/>
<fetchIndex name="titleIndex">
<fetchIndexElement property="title" type="Binary" order="ascending"/>
</fetchIndex>
<fetchIndex name="priorityIndex">
<fetchIndexElement property="priority" type="Binary" order="ascending"/>
</fetchIndex>
</entity>
<elements>
<element name="BenchDoc" positionX="-63" positionY="-18" width="128" height="178"/>
Expand Down
4 changes: 4 additions & 0 deletions app/Benchmarks/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ final class BenchmarksViewController: UIViewController {
for i in 0..<Self.NumberOfEntities {
let doc = NSManagedObject(entity: entity, insertInto: objectContext)
doc.setValue("title\(i)", forKeyPath: "title")
doc.setValue("tag\(i)", forKeyPath: "tag")
doc.setValue(0, forKeyPath: "pos_x")
doc.setValue(0, forKeyPath: "pos_y")
doc.setValue(0, forKeyPath: "pos_z")
switch i % 3 {
case 0:
doc.setValue(1, forKeyPath: "color")
Expand Down
1 change: 0 additions & 1 deletion app/Benchmarks/doc_generated.json

This file was deleted.

5 changes: 0 additions & 5 deletions app/Benchmarks/doc_mutating_generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ extension BenchDoc: SQLiteDflat.SQLiteAtom {
sqlite3_exec(sqlite.sqlite, "CREATE TABLE IF NOT EXISTS benchdoc (rowid INTEGER PRIMARY KEY AUTOINCREMENT, __pk0 TEXT, p BLOB, UNIQUE(__pk0))", nil, nil, nil)
}
public static func insertIndex(_ toolbox: PersistenceToolbox, field: String, rowid: Int64, table: ByteBuffer) -> Bool {
guard let sqlite = ((toolbox as? SQLitePersistenceToolbox).map { $0.connection }) else { return false }
switch field {
default:
break
}
return true
}
}
Expand Down
34 changes: 18 additions & 16 deletions src/parser/dflatc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -805,23 +805,25 @@ func GenChangeRequest(_ structDef: Struct, code: inout String) {
}
code += " }\n"
code += " public static func insertIndex(_ toolbox: PersistenceToolbox, field: String, rowid: Int64, table: ByteBuffer) -> Bool {\n"
code += " guard let sqlite = ((toolbox as? SQLitePersistenceToolbox).map { $0.connection }) else { return false }\n"
code += " switch field {\n"
for indexedField in indexedFields {
code += " case \"\(indexedField.keyName)\":\n"
code += " guard let insert = sqlite.prepareStatement(\"INSERT INTO \(tableName)__\(indexedField.keyName) (rowid, \(indexedField.keyName)) VALUES (?1, ?2)\") else { return false }\n"
code += " rowid.bindSQLite(insert, parameterId: 1)\n"
code += " let retval = \(GetIndexedFieldExpr(structDef, indexedField: indexedField)).evaluate(object: .table(table))\n"
code += " if retval.unknown {\n"
code += " sqlite3_bind_null(insert, 2)\n"
code += " } else {\n"
code += " retval.result.bindSQLite(insert, parameterId: 2)\n"
code += " }\n"
code += " guard SQLITE_DONE == sqlite3_step(insert) else { return false }\n"
if indexedFields.count > 0 {
code += " guard let sqlite = ((toolbox as? SQLitePersistenceToolbox).map { $0.connection }) else { return false }\n"
code += " switch field {\n"
for indexedField in indexedFields {
code += " case \"\(indexedField.keyName)\":\n"
code += " guard let insert = sqlite.prepareStatement(\"INSERT INTO \(tableName)__\(indexedField.keyName) (rowid, \(indexedField.keyName)) VALUES (?1, ?2)\") else { return false }\n"
code += " rowid.bindSQLite(insert, parameterId: 1)\n"
code += " let retval = \(GetIndexedFieldExpr(structDef, indexedField: indexedField)).evaluate(object: .table(table))\n"
code += " if retval.unknown {\n"
code += " sqlite3_bind_null(insert, 2)\n"
code += " } else {\n"
code += " retval.result.bindSQLite(insert, parameterId: 2)\n"
code += " }\n"
code += " guard SQLITE_DONE == sqlite3_step(insert) else { return false }\n"
}
code += " default:\n"
code += " break\n"
code += " }\n"
}
code += " default:\n"
code += " break\n"
code += " }\n"
code += " return true\n"
code += " }\n"
code += "}\n"
Expand Down
1 change: 0 additions & 1 deletion src/tests/monster_generated.json

This file was deleted.

1 change: 0 additions & 1 deletion src/tests/monster_v2_generated.json

This file was deleted.

0 comments on commit f8f301d

Please sign in to comment.