-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from dolthub/taylor/select-from
Workaround for current_database and current_schema
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bats | ||
load $BATS_TEST_DIRNAME/setup/common.bash | ||
|
||
setup() { | ||
setup_common | ||
start_sql_server | ||
query_server <<SQL | ||
CREATE TABLE test1 (pk BIGINT PRIMARY KEY, v1 SMALLINT); | ||
CREATE TABLE test2 (pk BIGINT PRIMARY KEY, v1 INTEGER, v2 SMALLINT); | ||
INSERT INTO test1 VALUES (1, 2), (6, 7); | ||
INSERT INTO test2 VALUES (3, 4, 5), (8, 9, 0); | ||
CREATE VIEW testview AS SELECT * FROM test1; | ||
SQL | ||
} | ||
|
||
teardown() { | ||
teardown_common | ||
} | ||
|
||
@test 'workbench-commands: current_schema' { | ||
run query_server -c "SELECT * FROM current_schema()" | ||
[ "$status" -eq 0 ] | ||
[[ "$output" =~ "public" ]] || false | ||
|
||
run query_server <<SQL | ||
CREATE SCHEMA test_schema; | ||
SET search_path TO test_schema; | ||
SELECT * FROM current_schema(); | ||
SQL | ||
[ "$status" -eq 0 ] | ||
[[ "$output" =~ "test_schema" ]] || false | ||
} | ||
|
||
@test 'workbench-commands: current_database' { | ||
run query_server -c "SELECT * FROM current_database();" | ||
[ "$status" -eq 0 ] | ||
[[ "$output" =~ "doltgres" ]] || false | ||
|
||
run query_server -c "CREATE DATABASE newdb;" | ||
[ "$status" -eq 0 ] | ||
|
||
run query_server_for_db newdb -c "SELECT * FROM current_database()" | ||
[ "$status" -eq 0 ] | ||
[[ "$output" =~ "newdb" ]] || false | ||
} |