-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonard Wolters
committed
May 28, 2024
1 parent
32eca06
commit 1c5925a
Showing
2 changed files
with
42 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 25 additions & 14 deletions
39
dsl/src/test/scala/com/crobox/clickhouse/dsl/language/SplitMergeFunctionTokenizerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
package com.crobox.clickhouse.dsl.language | ||
|
||
import com.crobox.clickhouse.dsl._ | ||
import com.crobox.clickhouse.{dsl, DslTestSpec} | ||
import com.crobox.clickhouse.{DslTestSpec, dsl} | ||
|
||
class SplitMergeFunctionTokenizerTest extends DslTestSpec { | ||
val FIELD_DELIMITER: Char = '\u001F' | ||
|
||
it should "splitByChar using special character" in { | ||
|
||
toSQL(select(dsl.splitByChar(FIELD_DELIMITER.toString, "abcd"))) should matchSQL( | ||
"SELECT splitByChar(char(31),'abcd')" | ||
"SELECT splitByChar(char(31), 'abcd')" | ||
) | ||
toSQL(select(dsl.splitByChar(31.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(31),'abcd')") | ||
toSQL(select(dsl.splitByChar(32.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(' ','abcd')") | ||
toSQL(select(dsl.splitByChar(126.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar('~','abcd')") | ||
toSQL(select(dsl.splitByChar(127.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(127),'abcd')") | ||
toSQL(select(dsl.splitByChar(128.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(128),'abcd')") | ||
toSQL(select(dsl.splitByChar(159.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(159),'abcd')") | ||
toSQL(select(dsl.splitByChar(31.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(31), 'abcd')") | ||
toSQL(select(dsl.splitByChar(32.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(' ', 'abcd')") | ||
toSQL(select(dsl.splitByChar(126.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar('~', 'abcd')") | ||
toSQL(select(dsl.splitByChar(127.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(127), 'abcd')") | ||
toSQL(select(dsl.splitByChar(128.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(128), 'abcd')") | ||
toSQL(select(dsl.splitByChar(159.toChar.toString, "abcd"))) should matchSQL("SELECT splitByChar(char(159), 'abcd')") | ||
|
||
toSQL(select(dsl.splitByChar(",", "abcd"))) should matchSQL("SELECT splitByChar(',','abcd')") | ||
toSQL(select(dsl.splitByChar("a", "abcd"))) should matchSQL("SELECT splitByChar('a','abcd')") | ||
toSQL(select(dsl.splitByChar("ab", "abcd"))) should matchSQL("SELECT splitByString('ab','abcd')") | ||
toSQL(select(dsl.splitByChar("L", "abcd"))) should matchSQL("SELECT splitByChar('L','abcd')") | ||
toSQL(select(dsl.splitByChar("$", "abcd"))) should matchSQL("SELECT splitByChar('$','abcd')") | ||
toSQL(select(dsl.splitByChar("-", "abcd"))) should matchSQL("SELECT splitByChar('-','abcd')") | ||
toSQL(select(dsl.splitByChar(",", "abcd"))) should matchSQL("SELECT splitByChar(',', 'abcd')") | ||
toSQL(select(dsl.splitByChar("a", "abcd"))) should matchSQL("SELECT splitByChar('a', 'abcd')") | ||
toSQL(select(dsl.splitByChar("L", "abcd"))) should matchSQL("SELECT splitByChar('L', 'abcd')") | ||
toSQL(select(dsl.splitByChar("$", "abcd"))) should matchSQL("SELECT splitByChar('$', 'abcd')") | ||
toSQL(select(dsl.splitByChar("-", "abcd"))) should matchSQL("SELECT splitByChar('-', 'abcd')") | ||
toSQL(select(dsl.splitByChar("!", "abcd"))) should matchSQL("SELECT splitByChar('!', 'abcd')") | ||
|
||
// special 'not quoted' characters, see ClickhouseStatement.UnquotedIdentifier | ||
toSQL(select(dsl.splitByChar("\"", "abcd"))) should matchSQL("SELECT splitByChar(char(34), 'abcd')") | ||
toSQL(select(dsl.splitByChar("'", "abcd"))) should matchSQL("SELECT splitByChar(char(39), 'abcd')") | ||
toSQL(select(dsl.splitByChar("`", "abcd"))) should matchSQL("SELECT splitByChar(char(96), 'abcd')") | ||
toSQL(select(dsl.splitByChar("\\", "abcd"))) should matchSQL("SELECT splitByChar(char(92), 'abcd')") | ||
toSQL(select(dsl.splitByChar("/", "abcd"))) should matchSQL("SELECT splitByChar('/', 'abcd')") | ||
|
||
// Multiple characters | ||
toSQL(select(dsl.splitByChar("ab", "abcd"))) should matchSQL("SELECT splitByString('ab', 'abcd')") | ||
toSQL(select(dsl.splitByChar("a'", "abcd"))) should matchSQL("SELECT splitByString('a\\'', 'abcd')") | ||
} | ||
} |