2424from google .type import expr_pb2
2525from . import _helpers
2626from . import _sample_data
27+ from google .cloud .spanner_admin_database_v1 import DatabaseDialect
2728
2829
2930DBAPI_OPERATION_TIMEOUT = 240 # seconds
@@ -226,7 +227,6 @@ def test_iam_policy(
226227 not_emulator ,
227228 shared_instance ,
228229 databases_to_delete ,
229- not_postgres ,
230230):
231231 pool = spanner_v1 .BurstyPool (labels = {"testcase" : "iam_policy" })
232232 temp_db_id = _helpers .unique_id ("iam_db" , separator = "_" )
@@ -407,27 +407,31 @@ def test_update_ddl_w_default_leader_success(
407407
408408
409409def test_create_role_grant_access_success (
410- not_emulator ,
411- shared_instance ,
412- databases_to_delete ,
413- not_postgres ,
410+ not_emulator , shared_instance , databases_to_delete , database_dialect
414411):
415412 creator_role_parent = _helpers .unique_id ("role_parent" , separator = "_" )
416413 creator_role_orphan = _helpers .unique_id ("role_orphan" , separator = "_" )
417414
418415 temp_db_id = _helpers .unique_id ("dfl_ldrr_upd_ddl" , separator = "_" )
419- temp_db = shared_instance .database (temp_db_id )
416+ temp_db = shared_instance .database (temp_db_id , database_dialect = database_dialect )
420417
421418 create_op = temp_db .create ()
422419 databases_to_delete .append (temp_db )
423420 create_op .result (DBAPI_OPERATION_TIMEOUT ) # raises on failure / timeout.
424-
425421 # Create role and grant select permission on table contacts for parent role.
426- ddl_statements = _helpers .DDL_STATEMENTS + [
427- f"CREATE ROLE { creator_role_parent } " ,
428- f"CREATE ROLE { creator_role_orphan } " ,
429- f"GRANT SELECT ON TABLE contacts TO ROLE { creator_role_parent } " ,
430- ]
422+ if database_dialect == DatabaseDialect .GOOGLE_STANDARD_SQL :
423+ ddl_statements = _helpers .DDL_STATEMENTS + [
424+ f"CREATE ROLE { creator_role_parent } " ,
425+ f"CREATE ROLE { creator_role_orphan } " ,
426+ f"GRANT SELECT ON TABLE contacts TO ROLE { creator_role_parent } " ,
427+ ]
428+ elif database_dialect == DatabaseDialect .POSTGRESQL :
429+ ddl_statements = _helpers .DDL_STATEMENTS + [
430+ f"CREATE ROLE { creator_role_parent } " ,
431+ f"CREATE ROLE { creator_role_orphan } " ,
432+ f"GRANT SELECT ON TABLE contacts TO { creator_role_parent } " ,
433+ ]
434+
431435 operation = temp_db .update_ddl (ddl_statements )
432436 operation .result (DBAPI_OPERATION_TIMEOUT ) # raises on failure / timeout.
433437
@@ -445,27 +449,31 @@ def test_create_role_grant_access_success(
445449 with temp_db .snapshot () as snapshot :
446450 snapshot .execute_sql ("SELECT * FROM contacts" )
447451
448- ddl_remove_roles = [
449- f"REVOKE SELECT ON TABLE contacts FROM ROLE { creator_role_parent } " ,
450- f"DROP ROLE { creator_role_parent } " ,
451- f"DROP ROLE { creator_role_orphan } " ,
452- ]
452+ if database_dialect == DatabaseDialect .GOOGLE_STANDARD_SQL :
453+ ddl_remove_roles = [
454+ f"REVOKE SELECT ON TABLE contacts FROM ROLE { creator_role_parent } " ,
455+ f"DROP ROLE { creator_role_parent } " ,
456+ f"DROP ROLE { creator_role_orphan } " ,
457+ ]
458+ elif database_dialect == DatabaseDialect .POSTGRESQL :
459+ ddl_remove_roles = [
460+ f"REVOKE SELECT ON TABLE contacts FROM { creator_role_parent } " ,
461+ f"DROP ROLE { creator_role_parent } " ,
462+ f"DROP ROLE { creator_role_orphan } " ,
463+ ]
453464 # Revoke permission and Delete roles.
454465 operation = temp_db .update_ddl (ddl_remove_roles )
455466 operation .result (DBAPI_OPERATION_TIMEOUT ) # raises on failure / timeout.
456467
457468
458469def test_list_database_role_success (
459- not_emulator ,
460- shared_instance ,
461- databases_to_delete ,
462- not_postgres ,
470+ not_emulator , shared_instance , databases_to_delete , database_dialect
463471):
464472 creator_role_parent = _helpers .unique_id ("role_parent" , separator = "_" )
465473 creator_role_orphan = _helpers .unique_id ("role_orphan" , separator = "_" )
466474
467475 temp_db_id = _helpers .unique_id ("dfl_ldrr_upd_ddl" , separator = "_" )
468- temp_db = shared_instance .database (temp_db_id )
476+ temp_db = shared_instance .database (temp_db_id , database_dialect = database_dialect )
469477
470478 create_op = temp_db .create ()
471479 databases_to_delete .append (temp_db )
0 commit comments