2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-18 20:45:21 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-674
|
|
|
|
ISSUE: 674
|
|
|
|
TITLE: ISQL and database dialect
|
|
|
|
DESCRIPTION:
|
|
|
|
::: NB :::
|
|
|
|
### Name of original test has no any relation with actual task of this test: ###
|
|
|
|
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_25.script
|
|
|
|
|
|
|
|
When ISQL disconnects from database (either by dropping it or by trying to connect to
|
|
|
|
non-existent database) is still remembers its sql dialect, which can lead to some
|
|
|
|
inappropriate warning messages.
|
|
|
|
|
|
|
|
Issue in original script: bug #910430 ISQL and database dialect
|
|
|
|
Found in FB tracker as: http://tracker.firebirdsql.org/browse/CORE-337
|
|
|
|
Fixed in 2.0 Beta 1
|
|
|
|
JIRA: CORE-337
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_0337
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2022-01-18 20:45:21 +01:00
|
|
|
from firebird.qa import *
|
|
|
|
|
|
|
|
db = db_factory()
|
|
|
|
|
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
SHOW SQL DIALECT;
|
2021-11-10 19:02:05 +01:00
|
|
|
Client SQL dialect has not been set and no database has been connected yet.
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
SET SQL DIALECT 1;
|
|
|
|
SHOW SQL DIALECT;
|
2021-11-10 19:02:05 +01:00
|
|
|
Client SQL dialect is set to: 1. No database has been connected.
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
SET SQL DIALECT 3;
|
|
|
|
CREATE DATABASE 'LOCALHOST:C:\\FBTESTING\\QA\\FBT-REPO\\TMP2\\TMP_0337.FDB' USER 'SYSDBA' PASSWORD 'MASTERKEY';
|
|
|
|
|
|
|
|
SHOW SQL DIALECT;
|
2021-11-10 19:02:05 +01:00
|
|
|
Client SQL dialect is set to: 3 and database SQL dialect is: 3
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
DROP DATABASE;
|
2021-11-10 19:02:05 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
SHOW DATABASE;
|
|
|
|
|
|
|
|
SHOW SQL DIALECT;
|
2021-11-10 19:02:05 +01:00
|
|
|
Client SQL dialect is set to: 3. No database has been connected.
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
SET SQL DIALECT 1;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
expected_stderr = """
|
2021-11-10 19:02:05 +01:00
|
|
|
Use CONNECT or CREATE DATABASE to specify a database
|
|
|
|
Use CONNECT or CREATE DATABASE to specify a database
|
|
|
|
Command error: SHOW DATABASE
|
|
|
|
"""
|
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
act = isql_act('db', "", substitutions=[('[ \t]+', ' '), ('CREATE DATABASE.*', 'CREATE DATABASE')])
|
2021-11-10 19:02:05 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
@pytest.mark.version('>=2.5')
|
2022-01-18 20:45:21 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.db.drop()
|
|
|
|
act.script = f"""
|
2021-11-10 19:02:05 +01:00
|
|
|
SET ECHO ON;
|
|
|
|
SHOW SQL DIALECT;
|
|
|
|
SET SQL DIALECT 1;
|
|
|
|
SHOW SQL DIALECT;
|
|
|
|
SET SQL DIALECT 3;
|
2022-01-18 20:45:21 +01:00
|
|
|
CREATE DATABASE '{act.db.dsn}' USER '{act.db.user}' PASSWORD '{act.db.password}';
|
2021-11-10 19:02:05 +01:00
|
|
|
SHOW SQL DIALECT;
|
|
|
|
DROP DATABASE;
|
|
|
|
SHOW DATABASE;
|
|
|
|
SHOW SQL DIALECT;
|
|
|
|
SET SQL DIALECT 1;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2022-01-18 20:45:21 +01:00
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.expected_stderr = expected_stderr
|
|
|
|
act.execute(do_not_connect=True)
|
|
|
|
assert (act.clean_stdout == act.clean_expected_stdout and act.clean_stderr == act.clean_expected_stderr)
|
|
|
|
act.db.create() # For cleanup
|
2021-11-10 19:02:05 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|