Skip to content

Commit 89f3ac8

Browse files
committed
add MotherDuck token only one time for multi-catalog
1 parent 7326de6 commit 89f3ac8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sqlmesh/core/config/connection.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -264,24 +264,24 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
264264
)
265265
try:
266266
if isinstance(path_options, DuckDBAttachOptions):
267-
if path_options.type == "motherduck":
268-
continue
269267
query = path_options.to_sql(alias)
270268
else:
271269
query = f"ATTACH '{path_options}'"
272270
if not path_options.startswith("md:"):
273271
query += f" AS {alias}"
274-
else:
275-
continue
276272
cursor.execute(query)
277273
except BinderException as e:
278274
# If a user tries to create a catalog pointing at `:memory:` and with the name `memory`
279275
# then we don't want to raise since this happens by default. They are just doing this to
280276
# set it as the default catalog.
277+
# If a user tried to attach a MotherDuck database/share which has already by attached via
278+
# `ATTACH 'md:'`, then we don't want to raise since this is expected.
281279
if not (
282280
'database with name "memory" already exists' in str(e)
283281
and path_options == ":memory:"
284-
) and not (f'database with name "{alias}" already exists' in str(e)):
282+
) and not (
283+
f'database with name "{alias}" already exists' in str(e)
284+
):
285285
raise e
286286
if i == 0 and not getattr(self, "database", None):
287287
cursor.execute(f"USE {alias}")

0 commit comments

Comments
 (0)