Skip to content

Commit f74adf5

Browse files
committed
v3.0.1 Bug Fixes
Closed #17 Closed #18 Closed #19
1 parent ae6f99a commit f74adf5

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CoreDataQueryInterface/CustomExpressionConvertible.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ extension CustomExpressionConvertible {
5252
var expressions = [AnyObject]()
5353
for elem in rhs {
5454
let o = elem as! AnyObject
55-
let e = NSExpression(forConstantValue: o)
55+
let e: NSExpression
56+
if let c = o as? CustomExpressionConvertible {
57+
e = c.expression
58+
} else {
59+
e = NSExpression(forConstantValue: o)
60+
}
5661
expressions.append(e)
5762
}
5863
return compare(NSExpression(forAggregate: expressions), type: .InPredicateOperatorType, options: options)

CoreDataQueryInterface/KeyAttribute.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import Foundation
1111
/**
1212
Use this subclass of `Attribute` for simple keys.
1313
*/
14-
class KeyAttribute: Attribute, Aggregable {
15-
typealias AggregateType = KeyAttribute
14+
public class KeyAttribute: Attribute, Aggregable {
15+
public typealias AggregateType = KeyAttribute
1616
}

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ CDQI works its magic by creating proxy objects for each entity in your model, an
6969
// All of the code below is automatically generated by the cdqi tool.
7070

7171
class DepartmentAttribute: Attribute, Aggregable {
72-
private(set) lazy var name: KeyAttribute = { KeyAttribute("name", parent: self) }()
72+
private(set) lazy var name: KeyAttribute = { KeyAttribute("name", parent: self) }()
73+
private(set) lazy var employees: EmployeeAttribute = { EmployeeAttribute("employees", parent: self) }()
7374
}
7475

75-
// This assumes you have a managed entity called Department.
76+
// This assumes you have a managed object called Department.
7677
extension Department: EntityType {
77-
typealias EntityAttributeType = DepartmentAttribute
78+
typealias EntityAttributeType = DepartmentAttribute
7879
}
80+
7981
```
8082

8183
Here are some examples of the use of `cdqi`:

bin/cdqi

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,16 @@ end
127127

128128
entities = []
129129

130-
File::open(File::join(model_path, ".xccurrentversion")) do |fd|
131-
xml = REXML::Document::new(fd)
132-
model_path = File::join(model_path, REXML::XPath::first(xml, "//key[.='_XCCurrentVersionName']/following-sibling::string").text)
133-
$stderr.puts "NOTICE: Using data model at #{model_path}."
134-
model_path = File::join(model_path, 'contents')
130+
currentversion_path = File::join(model_path, '.xccurrentversion')
131+
if File::exists? currentversion_path
132+
File::open(currentversion_path) do |fd|
133+
xml = REXML::Document::new(fd)
134+
model_path = File::join(model_path, REXML::XPath::first(xml, "//key[.='_XCCurrentVersionName']/following-sibling::string").text)
135+
$stderr.puts "NOTICE: Using data model at #{model_path}."
136+
model_path = File::join(model_path, 'contents')
137+
end
138+
else
139+
model_path = File::join(model_path, "#{model}.xcdatamodel/contents")
135140
end
136141

137142
File::open(model_path) do |fd|
@@ -180,6 +185,8 @@ def write_file_header(io)
180185
io.puts "// Edit it at your own risk."
181186
io.puts "//"
182187
io.puts ""
188+
io.puts "import CoreDataQueryInterface"
189+
io.puts ""
183190
end
184191

185192
if $options.merged

0 commit comments

Comments
 (0)