diff --git a/templates/android/library/src/main/java/io/appwrite/Query.kt.twig b/templates/android/library/src/main/java/io/appwrite/Query.kt.twig index e9c5a9c88..7f4fbcd81 100644 --- a/templates/android/library/src/main/java/io/appwrite/Query.kt.twig +++ b/templates/android/library/src/main/java/io/appwrite/Query.kt.twig @@ -20,11 +20,11 @@ class Query { fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" - fun between(attribute: String, start: Int, end: Int) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: Double, end: Double) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: String, end: String) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) diff --git a/templates/dart/lib/query.dart.twig b/templates/dart/lib/query.dart.twig index 249a5f7db..a5763d79d 100644 --- a/templates/dart/lib/query.dart.twig +++ b/templates/dart/lib/query.dart.twig @@ -48,7 +48,7 @@ class Query { /// Filter resources where [attribute] is between [start] and [end] (inclusive). static String between(String attribute, dynamic start, dynamic end) => - _addQuery(attribute, 'between', [start, end]); + 'between("$attribute", ${_parseValues(start)}, ${_parseValues(end)})'; /// Filter resources where [attribute] starts with [value]. static String startsWith(String attribute, String value) => diff --git a/templates/deno/src/query.ts.twig b/templates/deno/src/query.ts.twig index dd7c7a1cc..ce87185fb 100644 --- a/templates/deno/src/query.ts.twig +++ b/templates/deno/src/query.ts.twig @@ -31,7 +31,7 @@ export class Query { `isNotNull("${attribute}")`; static between = (attribute: string, start: string|number, end: string|number): string => - `between("${attribute}", [${Query.parseValues(start)},${Query.parseValues(end)}])`; + `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`; static startsWith = (attribute: string, value: string): string => Query.addQuery(attribute, "startsWith", value); diff --git a/templates/dotnet/src/Appwrite/Query.cs.twig b/templates/dotnet/src/Appwrite/Query.cs.twig index c940f4d6b..f10bac28c 100644 --- a/templates/dotnet/src/Appwrite/Query.cs.twig +++ b/templates/dotnet/src/Appwrite/Query.cs.twig @@ -63,17 +63,17 @@ namespace Appwrite public static string Between(string attribute, string start, string end) { - return AddQuery(attribute, "between", new List { start, end }); + return $"between(\"{attribute}\", \"{start}\", \"{end}\")"; } public static string Between(string attribute, int start, int end) { - return AddQuery(attribute, "between", new List { start, end }); + return $"between(\"{attribute}\", {start}, {end})"; } public static string Between(string attribute, double start, double end) { - return AddQuery(attribute, "between", new List { start, end }); + return $"between(\"{attribute}\", {start}, {end})"; } public static string Select(List attributes) diff --git a/templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig b/templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig index e9c5a9c88..7f4fbcd81 100644 --- a/templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig +++ b/templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig @@ -20,11 +20,11 @@ class Query { fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" - fun between(attribute: String, start: Int, end: Int) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: Double, end: Double) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: String, end: String) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) diff --git a/templates/node/lib/query.js.twig b/templates/node/lib/query.js.twig index 06e0b389d..675b02b49 100644 --- a/templates/node/lib/query.js.twig +++ b/templates/node/lib/query.js.twig @@ -24,7 +24,7 @@ class Query { `isNotNull("${attribute}")`; static between = (attribute, start, end) => - Query.addQuery(attribute, "between", [start, end]); + `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})` static startsWith = (attribute, value) => Query.addQuery(attribute, "startsWith", value); diff --git a/templates/php/src/Query.php.twig b/templates/php/src/Query.php.twig index 5f4d515fd..e249e8fcc 100644 --- a/templates/php/src/Query.php.twig +++ b/templates/php/src/Query.php.twig @@ -120,7 +120,10 @@ class Query */ public static function between(string $attribute, $start, $end): string { - return self::addQuery($attribute, 'between', [$start, $end]); + $start = self::parseValues($start); + $end = self::parseValues($end); + + return "between(\"{$attribute}\", {$start}, {$end})"; } /** diff --git a/templates/python/package/query.py.twig b/templates/python/package/query.py.twig index da636720e..d970bd8c9 100644 --- a/templates/python/package/query.py.twig +++ b/templates/python/package/query.py.twig @@ -33,7 +33,7 @@ class Query: @staticmethod def between(attribute, start, end): - return Query.add_query(attribute, "between", [start, end]) + return f'between("{attribute}", {Query.parseValues(start)}, {Query.parseValues(end)})' @staticmethod def starts_with(attribute, value): diff --git a/templates/ruby/lib/container/query.rb.twig b/templates/ruby/lib/container/query.rb.twig index 00806943f..e62ee4b92 100644 --- a/templates/ruby/lib/container/query.rb.twig +++ b/templates/ruby/lib/container/query.rb.twig @@ -34,7 +34,7 @@ module {{spec.title | caseUcfirst}} end def between(attribute, start, ending) - return add_query(attribute, "between", [start, ending]) + return "between(\"#{attribute}\", #{parse_values(start)}, #{parse_values(ending)})" end def starts_with(attribute, value) @@ -81,13 +81,13 @@ module {{spec.title | caseUcfirst}} def add_query(attribute, method, value) if value.is_a?(Array) - "#{method}(\"#{attribute}\", [#{value.map {|item| parseValues(item)}.join(',')}])" + "#{method}(\"#{attribute}\", [#{value.map {|item| parse_values(item)}.join(',')}])" else - return "#{method}(\"#{attribute}\", [#{parseValues(value)}])" + return "#{method}(\"#{attribute}\", [#{parse_values(value)}])" end end - def parseValues(value) + def parse_values(value) return value.is_a?(String) ? "\"#{value}\"" : value end end diff --git a/templates/swift/Sources/Query.swift.twig b/templates/swift/Sources/Query.swift.twig index 9fa9893c7..ce1415d75 100644 --- a/templates/swift/Sources/Query.swift.twig +++ b/templates/swift/Sources/Query.swift.twig @@ -33,15 +33,15 @@ public class Query { } public static func between(_ attribute: String, start: Int, end: Int) -> String { - buildQueryWhere(attribute, is: "between", to: [start, end]) + "between(\"\(attribute)\", \(start), \(end))" } public static func between(_ attribute: String, start: Double, end: Double) -> String { - buildQueryWhere(attribute, is: "between", to: [start, end]) + "between(\"\(attribute)\", \(start), \(end))" } public static func between(_ attribute: String, start: String, end: String) -> String { - buildQueryWhere(attribute, is: "between", to: [start, end]) + "between(\"\(attribute)\", \"\(start)\", \"\(end)\")" } public static func startsWith(_ attribute: String, value: String) -> String { diff --git a/templates/web/src/query.ts.twig b/templates/web/src/query.ts.twig index 51cbb7a9f..1f880cb1c 100644 --- a/templates/web/src/query.ts.twig +++ b/templates/web/src/query.ts.twig @@ -28,7 +28,7 @@ export class Query { `isNotNull("${attribute}")`; static between = (attribute: string, start: string|number, end: string|number): string => - `between("${attribute}", [${Query.parseValues(start)},${Query.parseValues(end)}])`; + `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`; static startsWith = (attribute: string, value: string): string => Query.addQuery(attribute, "startsWith", value); diff --git a/tests/Base.php b/tests/Base.php index 464291b45..e0855595b 100644 --- a/tests/Base.php +++ b/tests/Base.php @@ -69,9 +69,9 @@ abstract class Base extends TestCase 'search("name", ["john"])', 'isNull("name")', 'isNotNull("name")', - 'between("age", [50,100])', - 'between("age", [50.5,100.5])', - 'between("name", ["Anna","Brad"])', + 'between("age", 50, 100)', + 'between("age", 50.5, 100.5)', + 'between("name", "Anna", "Brad")', 'startsWith("name", ["Ann"])', 'endsWith("name", ["nne"])', 'select(["name","age"])',