Skip to content

Commit b377b6a

Browse files
committed
Fixed issue with named params + null checks
- Took care of issue #10 - Updated docs with camlsql.lookup - Added changelog to docs
1 parent 99987d7 commit b377b6a

File tree

13 files changed

+76
-11
lines changed

13 files changed

+76
-11
lines changed

dist/camlsql.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,12 +1386,15 @@ var WhereParser = function(whereString, quiet) {
13861386
if (cmpMatch.toLowerCase() == 'cxqlisnotnull') comparison = "notnull";
13871387
if (cmpMatch.toLowerCase() == 'in') comparison = "in";
13881388

1389-
if (comparison != "cxqlisnull" && comparison != "cxqlisnotnull") {
1389+
if (comparison != "null" && comparison != "notnull") {
13901390
_parameters++;
13911391
_numMacros++;
13921392
if (prevMacro == null)
13931393
prevMacro = m[3][0];
13941394
else if (prevMacro != m[3][0]) {
1395+
1396+
console.log("prevMacro", prevMacro, comparison);
1397+
13951398
throw "[camlsql] You can not mix named macros and ?";
13961399
return null;
13971400
}

dist/camlsql.min.js

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

dist/public_html/js/camlsql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ var WhereParser = function(whereString, quiet) {
14301430
if (cmpMatch.toLowerCase() == 'cxqlisnotnull') comparison = "notnull";
14311431
if (cmpMatch.toLowerCase() == 'in') comparison = "in";
14321432

1433-
if (comparison != "cxqlisnull" && comparison != "cxqlisnotnull") {
1433+
if (comparison != "null" && comparison != "notnull") {
14341434
_parameters++;
14351435
_numMacros++;
14361436
if (prevMacro == null)

dist/public_html/js/camlsql.min.js

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

dist/public_html/js/release/camlsql.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,12 +1386,15 @@ var WhereParser = function(whereString, quiet) {
13861386
if (cmpMatch.toLowerCase() == 'cxqlisnotnull') comparison = "notnull";
13871387
if (cmpMatch.toLowerCase() == 'in') comparison = "in";
13881388

1389-
if (comparison != "cxqlisnull" && comparison != "cxqlisnotnull") {
1389+
if (comparison != "null" && comparison != "notnull") {
13901390
_parameters++;
13911391
_numMacros++;
13921392
if (prevMacro == null)
13931393
prevMacro = m[3][0];
13941394
else if (prevMacro != m[3][0]) {
1395+
1396+
console.log("prevMacro", prevMacro, comparison);
1397+
13951398
throw "[camlsql] You can not mix named macros and ?";
13961399
return null;
13971400
}

dist/public_html/js/release/camlsql.min.js

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

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- [Home](/)
22
- [Introduction](introduction.md)
33
- [Getting started](getstarted.md)
4+
- [Changelog](changelog.md)
45
- **Prepare your query**
56
- [SQL Syntax](sql.md#sql-syntax)
67
- [Bind Parameters](bind-parameters.md#bind-parameters)

docs/camlsql-object.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,58 @@ camlsql.prepare("SELECT * FROM [Pages] WHERE UniqueId = ?",
134134
</Eq>
135135
</Where>
136136
</Query>
137-
</View>s
137+
</View>
138+
```
139+
140+
### lookup method
141+
142+
?> ***object*** camlsql.**lookup**(***string*** value)<br>
143+
***object*** camlsql.**lookup**(***int*** value)
144+
145+
- Use a `int` parameter to create a lookup by ID setting the LookupId attribute to `true`
146+
- Use a `string` parameter to create a lookup by value
147+
148+
149+
#### LookupId
150+
151+
```
152+
<script>
153+
camlsql.prepare("SELECT * FROM List WHERE [MyLookup] = ?",
154+
[camlsql.lookup(5)]);
155+
</script>
156+
<View>
157+
<Query>
158+
<Where>
159+
<Eq>
160+
<FieldRef Name="MyLookup" LookupId="True" />
161+
<Value Type="Lookup" LookupId="True">5</Value>
162+
</Eq>
163+
</Where>
164+
</Query>
165+
</View>
166+
```
167+
168+
#### By value
169+
138170
```
171+
<script>
172+
camlsql.prepare("SELECT * FROM List WHERE [MyLookup] = ?",
173+
[camlsql.lookup("hello")]);
174+
</script>
175+
<View>
176+
<Query>
177+
<Where>
178+
<Eq>
179+
<FieldRef Name="MyLookup" />
180+
<Value Type="Lookup">Hello</Value>
181+
</Eq>
182+
</Where>
183+
</Query>
184+
</View>
185+
```
186+
139187

188+
camlsql.prepare("SELECT * FROM List WHERE [MyLookup] = ?", [camlsql.lookup(5)])
140189

141190
### membership method
142191

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## 0.5.1
4+
5+
- Added [camlsql.lookup](camlsql-object.md#lookup-method)
6+
- Fixed issue [#10 Named parameters and NULL / NOT NULL](https://github.com/dlid/camlsql-js/issues/10)
7+
8+
## 0.5.0
9+
10+
- First release

docs/getstarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Just want to get started huh? Here's some copy-pastable material for you!
55
## Include the script
66

77
```
8-
<script src="https://cdn.rawgit.com/dlid/camlsql-js/0.5.0/dist/camlsql.min.js"></script>
8+
<script src="https://cdn.rawgit.com/dlid/camlsql-js/0.5.1/dist/camlsql.min.js"></script>
99
```
1010

1111
## Prepare your query

0 commit comments

Comments
 (0)