Skip to content

Commit ba845bb

Browse files
authored
Merge pull request #39 from codeforkjeff/dbt-1-4-0-compat
dbt 1.4.0 compatibility
2 parents 10c7969 + 8e0657d commit ba845bb

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y install git python3 python3-pip python3-venv sq
88
WORKDIR /opt/dbt-sqlite
99

1010
RUN python3 -m pip install --upgrade pip \
11-
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.3.0 dbt-tests-adapter~=1.3.0
11+
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.4.0 dbt-tests-adapter~=1.4.0
1212

1313
RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/crypto.so
1414
RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/math.so

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Use the right version. Starting with the release of dbt-core 1.0.0,
3434
versions of dbt-sqlite are aligned to the same major+minor
3535
[version](https://semver.org/) of dbt-core.
3636

37+
- versions 1.4.x of this adapter work with dbt-core 1.4.x
38+
- versions 1.3.x of this adapter work with dbt-core 1.3.x
3739
- versions 1.2.x of this adapter work with dbt-core 1.2.x
3840
- versions 1.1.x of this adapter work with dbt-core 1.1.x
3941
- versions 1.0.x of this adapter work with dbt-core 1.0.x

dbt/adapters/sqlite/connections.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from dbt.contracts.connection import AdapterResponse
1313
from dbt.contracts.connection import Connection
1414
from dbt.exceptions import (
15-
DatabaseException,
16-
FailedToConnectException,
17-
RuntimeException
15+
DbtDatabaseError,
16+
FailedToConnectError,
17+
DbtRuntimeError
1818
)
1919
from dbt.logger import GLOBAL_LOGGER as logger
2020

@@ -66,7 +66,7 @@ def open(cls, connection: Connection):
6666
handle: sqlite3.Connection = sqlite3.connect(schemas_and_paths['main'])
6767
attached.append(schemas_and_paths['main'])
6868
else:
69-
raise FailedToConnectException("at least one schema must be called 'main'")
69+
raise FailedToConnectError("at least one schema must be called 'main'")
7070

7171
if len(credentials.extensions) > 0:
7272
handle.enable_load_extension(True)
@@ -92,7 +92,7 @@ def open(cls, connection: Connection):
9292
if schema not in attached:
9393
cursor.execute(f"attach '{path}' as '{schema}'")
9494
else:
95-
raise FailedToConnectException(
95+
raise FailedToConnectError(
9696
f"found {path} while scanning schema_directory, but cannot attach it as '{schema}' " +
9797
f"because that schema name is already defined in schemas_and_paths. " +
9898
f"fix your ~/.dbt/profiles.yml file")
@@ -112,7 +112,7 @@ def open(cls, connection: Connection):
112112
connection.handle = None
113113
connection.state = "fail"
114114

115-
raise FailedToConnectException(str(e))
115+
raise FailedToConnectError(str(e))
116116
except Exception as e:
117117
print(f"Unknown error opening SQLite connection: {e}")
118118
raise e
@@ -151,12 +151,12 @@ def exception_handler(self, sql: str):
151151
except sqlite3.DatabaseError as e:
152152
self.release()
153153
logger.debug("sqlite3 error: {}".format(str(e)))
154-
raise DatabaseException(str(e))
154+
raise DbtDatabaseError(str(e))
155155
except Exception as e:
156156
logger.debug("Error running SQL: {}".format(sql))
157157
logger.debug("Rolling back transaction.")
158158
self.release()
159-
raise RuntimeException(str(e))
159+
raise DbtRuntimeError(str(e))
160160

161161
def add_query(
162162
self,

dbt/adapters/sqlite/impl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from dbt.adapters.sqlite import SQLiteConnectionManager
1313
from dbt.adapters.sqlite.relation import SQLiteRelation
1414
from dbt.contracts.graph.manifest import Manifest
15-
from dbt.exceptions import NotImplementedException
15+
from dbt.exceptions import NotImplementedError
1616

1717

1818
class SQLiteAdapter(SQLAdapter):
@@ -93,7 +93,7 @@ def rename_relation(self, from_relation, to_relation):
9393
self.connections.execute(new_definition)
9494

9595
else:
96-
raise NotImplementedException(
96+
raise NotImplementedError(
9797
f"I don't know how to rename this type of relation: {from_relation.type}," +
9898
f" from: {from_relation}, to: {to_relation}")
9999

dbt/adapters/sqlite/relation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22

33
from dbt.adapters.base.relation import BaseRelation, Policy
44

@@ -19,5 +19,5 @@ class SQLiteIncludePolicy(Policy):
1919

2020
@dataclass(frozen=True, eq=False, repr=False)
2121
class SQLiteRelation(BaseRelation):
22-
quote_policy: SQLiteQuotePolicy = SQLiteQuotePolicy()
23-
include_policy: SQLiteIncludePolicy = SQLiteIncludePolicy()
22+
quote_policy: SQLiteQuotePolicy = field(default_factory=SQLiteQuotePolicy)
23+
include_policy: SQLiteIncludePolicy = field(default_factory=SQLiteIncludePolicy)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _get_plugin_version():
4646
]
4747
},
4848
install_requires=[
49-
"dbt-core>=1.3.0"
49+
"dbt-core>=1.4.0"
5050
],
5151
classifiers=[
5252
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)