@@ -4,24 +4,25 @@ import dev.mongocamp.driver.mongodb._
4
4
import dev .mongocamp .driver .mongodb .database .DatabaseProvider
5
5
import SQLCommandType .SQLCommandType
6
6
import com .mongodb .client .model .DropIndexOptions
7
- import net .sf .jsqlparser .statement .{ShowStatement , Statement , UnsupportedStatement }
8
- import net .sf .jsqlparser .expression .operators .conditional .{AndExpression , OrExpression }
7
+ import dev .mongocamp .driver .mongodb .database .DatabaseProvider .CollectionSeparator
8
+ import net .sf .jsqlparser .statement .{ ShowStatement , Statement , UnsupportedStatement }
9
+ import net .sf .jsqlparser .expression .operators .conditional .{ AndExpression , OrExpression }
9
10
import net .sf .jsqlparser .expression .operators .relational ._
10
- import net .sf .jsqlparser .expression .{Expression , Parenthesis }
11
- import net .sf .jsqlparser .parser .{CCJSqlParser , StreamProvider }
12
- import net .sf .jsqlparser .schema .{Column , Table }
11
+ import net .sf .jsqlparser .expression .{ Expression , Parenthesis }
12
+ import net .sf .jsqlparser .parser .{ CCJSqlParser , StreamProvider }
13
+ import net .sf .jsqlparser .schema .{ Column , Table }
13
14
import net .sf .jsqlparser .statement .create .index .CreateIndex
14
15
import net .sf .jsqlparser .statement .delete .Delete
15
16
import net .sf .jsqlparser .statement .drop .Drop
16
17
import net .sf .jsqlparser .statement .insert .Insert
17
- import net .sf .jsqlparser .statement .select .{AllColumns , FromItem , PlainSelect , Select , SelectItem }
18
+ import net .sf .jsqlparser .statement .select .{ AllColumns , FromItem , PlainSelect , Select , SelectItem }
18
19
import net .sf .jsqlparser .statement .show .ShowTablesStatement
19
20
import net .sf .jsqlparser .statement .truncate .Truncate
20
21
import net .sf .jsqlparser .statement .update .Update
21
22
import org .bson .conversions .Bson
22
23
import org .mongodb .scala .model .IndexOptions
23
24
import org .mongodb .scala .model .Sorts .ascending
24
- import org .mongodb .scala .{Document , Observable }
25
+ import org .mongodb .scala .{ Document , Observable }
25
26
26
27
import java .util .concurrent .TimeUnit
27
28
import scala .collection .mutable
@@ -90,11 +91,12 @@ class MongoSqlQueryHolder {
90
91
}
91
92
else if (classOf [UnsupportedStatement ].isAssignableFrom(statement.getClass)) {
92
93
val unsupportedStatement = statement.asInstanceOf [UnsupportedStatement ]
93
- val isShowDatabases = unsupportedStatement.toString.toLowerCase.contains(" show databases" )
94
- val isShowSchemas = unsupportedStatement.toString.toLowerCase.contains(" show schemas" )
94
+ val isShowDatabases = unsupportedStatement.toString.toLowerCase.contains(" show databases" )
95
+ val isShowSchemas = unsupportedStatement.toString.toLowerCase.contains(" show schemas" )
95
96
if (isShowDatabases | isShowSchemas) {
96
97
sqlCommandType = SQLCommandType .ShowDatabases
97
- } else {
98
+ }
99
+ else {
98
100
throw new IllegalArgumentException (" not supported sql command type" )
99
101
}
100
102
}
@@ -104,7 +106,9 @@ class MongoSqlQueryHolder {
104
106
" "
105
107
}
106
108
107
- def getCollection : String = sqlTable.getFullyQualifiedName
109
+ def getCollection : String = {
110
+ sqlTable.getFullyQualifiedName.replace(" ." , CollectionSeparator ).replace(" '" , " " ).replace(" `" , " " )
111
+ }
108
112
109
113
def run (provider : DatabaseProvider , allowDiskUsage : Boolean = true ): Observable [Document ] = {
110
114
sqlCommandType match {
0 commit comments