diff --git a/Dockerfile b/Dockerfile index 324ff92..c531b93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y install git python3 python3-pip python3-venv sq WORKDIR /opt/dbt-sqlite RUN python3 -m pip install --upgrade pip \ - && python3 -m pip install pytest pytest-dotenv dbt-core~=1.3.0 dbt-tests-adapter~=1.3.0 + && python3 -m pip install pytest pytest-dotenv dbt-core~=1.4.0 dbt-tests-adapter~=1.4.0 RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/crypto.so RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/math.so diff --git a/README.md b/README.md index 0da03b8..15628bb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Use the right version. Starting with the release of dbt-core 1.0.0, versions of dbt-sqlite are aligned to the same major+minor [version](https://semver.org/) of dbt-core. +- versions 1.4.x of this adapter work with dbt-core 1.4.x +- versions 1.3.x of this adapter work with dbt-core 1.3.x - versions 1.2.x of this adapter work with dbt-core 1.2.x - versions 1.1.x of this adapter work with dbt-core 1.1.x - versions 1.0.x of this adapter work with dbt-core 1.0.x diff --git a/dbt/adapters/sqlite/connections.py b/dbt/adapters/sqlite/connections.py index 140a65e..bd37deb 100644 --- a/dbt/adapters/sqlite/connections.py +++ b/dbt/adapters/sqlite/connections.py @@ -12,9 +12,9 @@ from dbt.contracts.connection import AdapterResponse from dbt.contracts.connection import Connection from dbt.exceptions import ( - DatabaseException, - FailedToConnectException, - RuntimeException + DbtDatabaseError, + FailedToConnectError, + DbtRuntimeError ) from dbt.logger import GLOBAL_LOGGER as logger @@ -66,7 +66,7 @@ def open(cls, connection: Connection): handle: sqlite3.Connection = sqlite3.connect(schemas_and_paths['main']) attached.append(schemas_and_paths['main']) else: - raise FailedToConnectException("at least one schema must be called 'main'") + raise FailedToConnectError("at least one schema must be called 'main'") if len(credentials.extensions) > 0: handle.enable_load_extension(True) @@ -92,7 +92,7 @@ def open(cls, connection: Connection): if schema not in attached: cursor.execute(f"attach '{path}' as '{schema}'") else: - raise FailedToConnectException( + raise FailedToConnectError( f"found {path} while scanning schema_directory, but cannot attach it as '{schema}' " + f"because that schema name is already defined in schemas_and_paths. " + f"fix your ~/.dbt/profiles.yml file") @@ -112,7 +112,7 @@ def open(cls, connection: Connection): connection.handle = None connection.state = "fail" - raise FailedToConnectException(str(e)) + raise FailedToConnectError(str(e)) except Exception as e: print(f"Unknown error opening SQLite connection: {e}") raise e @@ -151,12 +151,12 @@ def exception_handler(self, sql: str): except sqlite3.DatabaseError as e: self.release() logger.debug("sqlite3 error: {}".format(str(e))) - raise DatabaseException(str(e)) + raise DbtDatabaseError(str(e)) except Exception as e: logger.debug("Error running SQL: {}".format(sql)) logger.debug("Rolling back transaction.") self.release() - raise RuntimeException(str(e)) + raise DbtRuntimeError(str(e)) def add_query( self, diff --git a/dbt/adapters/sqlite/impl.py b/dbt/adapters/sqlite/impl.py index bcd1d4c..7b15fb5 100644 --- a/dbt/adapters/sqlite/impl.py +++ b/dbt/adapters/sqlite/impl.py @@ -12,7 +12,7 @@ from dbt.adapters.sqlite import SQLiteConnectionManager from dbt.adapters.sqlite.relation import SQLiteRelation from dbt.contracts.graph.manifest import Manifest -from dbt.exceptions import NotImplementedException +from dbt.exceptions import NotImplementedError class SQLiteAdapter(SQLAdapter): @@ -93,7 +93,7 @@ def rename_relation(self, from_relation, to_relation): self.connections.execute(new_definition) else: - raise NotImplementedException( + raise NotImplementedError( f"I don't know how to rename this type of relation: {from_relation.type}," + f" from: {from_relation}, to: {to_relation}") diff --git a/dbt/adapters/sqlite/relation.py b/dbt/adapters/sqlite/relation.py index 3680268..9f84a76 100644 --- a/dbt/adapters/sqlite/relation.py +++ b/dbt/adapters/sqlite/relation.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass +from dataclasses import dataclass, field from dbt.adapters.base.relation import BaseRelation, Policy @@ -19,5 +19,5 @@ class SQLiteIncludePolicy(Policy): @dataclass(frozen=True, eq=False, repr=False) class SQLiteRelation(BaseRelation): - quote_policy: SQLiteQuotePolicy = SQLiteQuotePolicy() - include_policy: SQLiteIncludePolicy = SQLiteIncludePolicy() + quote_policy: SQLiteQuotePolicy = field(default_factory=SQLiteQuotePolicy) + include_policy: SQLiteIncludePolicy = field(default_factory=SQLiteIncludePolicy) diff --git a/setup.py b/setup.py index 4248288..0ac10e9 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ def _get_plugin_version(): ] }, install_requires=[ - "dbt-core>=1.3.0" + "dbt-core>=1.4.0" ], classifiers=[ 'Development Status :: 4 - Beta',