Skip to content

Commit bee7327

Browse files
tailhookfantix
authored andcommitted
Implement database config in project dir (#442)
Complements geldata/gel-cli#1086
1 parent 0f30b26 commit bee7327

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

edgedb/con_utils.py

+6
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,12 @@ def _parse_connect_dsn_and_args(
706706
f'project defined cloud profile ("{cloud_profile}")'
707707
),
708708
)
709+
710+
opt_database_file = os.path.join(stash_dir, 'database')
711+
if os.path.exists(opt_database_file):
712+
with open(opt_database_file, 'rt') as f:
713+
database = f.read().strip()
714+
resolved_config.set_database(database, "project")
709715
else:
710716
raise errors.ClientConnectionError(
711717
f'Found `edgedb.toml` but the project is not initialized. '

tests/test_con_utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333

3434
class TestConUtils(unittest.TestCase):
35+
maxDiff = 1000
3536

3637
error_mapping = {
3738
'credentials_file_not_found': (
@@ -184,6 +185,9 @@ def run_testcase(self, testcase):
184185
if 'cloud-profile' in v:
185186
profile = os.path.join(dir, 'cloud-profile')
186187
files[profile] = v['cloud-profile']
188+
if 'database' in v:
189+
database_file = os.path.join(dir, 'database')
190+
files[database_file] = v['database']
187191
del files[f]
188192

189193
es.enter_context(

0 commit comments

Comments
 (0)