Skip to content

Commit 818125b

Browse files
committed
Fix string betweens
1 parent 7b3a6ce commit 818125b

File tree

11 files changed

+17
-13
lines changed

11 files changed

+17
-13
lines changed

templates/android/library/src/main/java/io/appwrite/Query.kt.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Query {
2424

2525
fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})"
2626

27-
fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", ${start}, ${end})"
27+
fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")"
2828

2929
fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value)
3030

templates/dart/lib/query.dart.twig

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class Query {
4747
static String isNotNull(String attribute) => 'isNotNull("$attribute")';
4848

4949
/// Filter resources where [attribute] is between [start] and [end] (inclusive).
50-
static String between(String attribute, dynamic start, dynamic end) => 'between("$attribute", $start, $end)'
50+
static String between(String attribute, dynamic start, dynamic end) =>
51+
'between("$attribute", ${_parseValues(start)}, ${_parseValues(end)})';
5152

5253
/// Filter resources where [attribute] starts with [value].
5354
static String startsWith(String attribute, String value) =>

templates/deno/src/query.ts.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Query {
3131
`isNotNull("${attribute}")`;
3232

3333
static between = (attribute: string, start: string|number, end: string|number): string =>
34-
`between("${attribute}", ${start}, ${end})`;
34+
`between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`;
3535

3636
static startsWith = (attribute: string, value: string): string =>
3737
Query.addQuery(attribute, "startsWith", value);

templates/dotnet/src/Appwrite/Query.cs.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace Appwrite
6363

6464
public static string Between(string attribute, string start, string end)
6565
{
66-
return $"between(\"{attribute}\", {start}, {end})";
66+
return $"between(\"{attribute}\", \"{start}\", \"{end}\")";
6767
}
6868

6969
public static string Between(string attribute, int start, int end)

templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Query {
2424

2525
fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})"
2626

27-
fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", ${start}, ${end})"
27+
fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")"
2828

2929
fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value)
3030

templates/node/lib/query.js.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Query {
2424
`isNotNull("${attribute}")`;
2525

2626
static between = (attribute, start, end) =>
27-
`between("${attribute}", ${start}, ${end})`
27+
`between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`
2828

2929
static startsWith = (attribute, value) =>
3030
Query.addQuery(attribute, "startsWith", value);

templates/php/src/Query.php.twig

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class Query
120120
*/
121121
public static function between(string $attribute, $start, $end): string
122122
{
123+
$start = self::parseValues($start);
124+
$end = self::parseValues($end);
125+
123126
return "between(\"{$attribute}\", {$start}, {$end})";
124127
}
125128

templates/python/package/query.py.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Query:
3333

3434
@staticmethod
3535
def between(attribute, start, end):
36-
return f'between("{attribute}", {start}, {end})'
36+
return f'between("{attribute}", {Query.parseValues(start)}, {Query.parseValues(end)})'
3737

3838
@staticmethod
3939
def starts_with(attribute, value):

templates/ruby/lib/container/query.rb.twig

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module {{spec.title | caseUcfirst}}
3434
end
3535

3636
def between(attribute, start, end)
37-
return "between(\"#{attribute}\", #{start}, #{end})"
37+
return "between(\"#{attribute}\", #{parse_values(start)}, #{parse_values(end)})"
3838
end
3939

4040
def starts_with(attribute, value)
@@ -81,13 +81,13 @@ module {{spec.title | caseUcfirst}}
8181

8282
def add_query(attribute, method, value)
8383
if value.is_a?(Array)
84-
"#{method}(\"#{attribute}\", [#{value.map {|item| parseValues(item)}.join(',')}])"
84+
"#{method}(\"#{attribute}\", [#{value.map {|item| parse_values(item)}.join(',')}])"
8585
else
86-
return "#{method}(\"#{attribute}\", [#{parseValues(value)}])"
86+
return "#{method}(\"#{attribute}\", [#{parse_values(value)}])"
8787
end
8888
end
8989

90-
def parseValues(value)
90+
def parse_values(value)
9191
return value.is_a?(String) ? "\"#{value}\"" : value
9292
end
9393
end

templates/swift/Sources/Query.swift.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Query {
4141
}
4242

4343
public static func between(_ attribute: String, start: String, end: String) -> String {
44-
"between(\"\(attribute)\", \(start), \(end))"
44+
"between(\"\(attribute)\", \"\(start)\", \"\(end)\")"
4545
}
4646

4747
public static func startsWith(_ attribute: String, value: String) -> String {

templates/web/src/query.ts.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Query {
2828
`isNotNull("${attribute}")`;
2929

3030
static between = (attribute: string, start: string|number, end: string|number): string =>
31-
`between("${attribute}", ${start},${end}])`;
31+
`between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)}])`;
3232

3333
static startsWith = (attribute: string, value: string): string =>
3434
Query.addQuery(attribute, "startsWith", value);

0 commit comments

Comments
 (0)