Skip to content

Commit

Permalink
Merge pull request sinzlab#45 from cblessing24/fix_issue44
Browse files Browse the repository at this point in the history
Fix `CURRENT_TIMESTAMP` breaking local table creation on mariadb
  • Loading branch information
christoph-blessing authored Oct 5, 2023
2 parents 3a89f03 + 93f707d commit 84ac630
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion link/infrastructure/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ def create_table_definition_provider(table: Callable[[], dj.Table]) -> Callable[
"""Create an object that provides the definition of the table produced by the given factory when called."""

def provide_definition() -> str:
return str(table().heading)
return str(table().heading).replace('"current_timestamp()"', "CURRENT_TIMESTAMP")

return provide_definition
2 changes: 1 addition & 1 deletion tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

SCOPE = os.environ.get("SCOPE", "session")
REMOVE = True
DATABASE_IMAGE = "datajoint/mysql:latest"
DATABASE_IMAGE = "cblessing24/mariadb:11.1"
MINIO_IMAGE = "minio/minio:latest"
DATABASE_ROOT_PASSWORD = "root"

Expand Down
19 changes: 19 additions & 0 deletions tests/functional/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ def test_local_table_creation_from_source_table_that_has_parent_raises_no_error(
"Outbound",
schema_names["local"],
)(type(source_table_name, (dj.Manual,), {}))


def test_local_table_creation_from_source_table_that_uses_current_timestamp_default_raises_no_error(
prepare_link, create_table, prepare_table, databases, configured_environment, connection_config
):
schema_names, user_specs = prepare_link()
source_table_name = "Foo"
source_table = create_table(source_table_name, dj.Manual, "foo = CURRENT_TIMESTAMP : timestamp")
prepare_table(databases["source"], user_specs["source"], schema_names["source"], source_table)
with connection_config(databases["local"], user_specs["local"]), configured_environment(
user_specs["link"], schema_names["outbound"]
):
link(
databases["source"].container.name,
schema_names["source"],
schema_names["outbound"],
"Outbound",
schema_names["local"],
)(type(source_table_name, (dj.Manual,), {}))

0 comments on commit 84ac630

Please sign in to comment.