Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Mar 11, 2022
2 parents cd37084 + 2936677 commit 6b5fa27
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion emmett/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.4.4"
__version__ = "2.4.5"
44 changes: 26 additions & 18 deletions emmett/orm/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from functools import wraps

from pydal.adapters import adapters
from pydal.adapters.base import SQLAdapter
from pydal.adapters.mssql import (
MSSQL1,
MSSQL3,
Expand Down Expand Up @@ -64,21 +65,26 @@ def wrapped(*args, **kwargs):


def patch_adapter(adapter):
adapter.insert = _wrap_on_obj(insert, adapter)
adapter.iterselect = _wrap_on_obj(iterselect, adapter)
adapter.parse = _wrap_on_obj(parse, adapter)
adapter.iterparse = _wrap_on_obj(iterparse, adapter)
adapter._parse_expand_colnames = _wrap_on_obj(_parse_expand_colnames, adapter)
adapter._parse = _wrap_on_obj(_parse, adapter)
#: BaseAdapter interfaces
adapter._expand_all_with_concrete_tables = _wrap_on_obj(
_expand_all_with_concrete_tables, adapter
)
adapter._parse = _wrap_on_obj(_parse, adapter)
adapter._parse_expand_colnames = _wrap_on_obj(_parse_expand_colnames, adapter)
adapter.iterparse = _wrap_on_obj(iterparse, adapter)
adapter.parse = _wrap_on_obj(parse, adapter)
patch_parser(adapter.dialect, adapter.parser)
patch_representer(adapter.representer)

#: SQLAdapter interfaces
if not isinstance(adapter, SQLAdapter):
return
adapter._select_aux = _wrap_on_obj(_select_aux, adapter)
adapter._select_wcols_inner = adapter._select_wcols
adapter._select_wcols = _wrap_on_obj(_select_wcols, adapter)
adapter._select_aux = _wrap_on_obj(_select_aux, adapter)
adapter.insert = _wrap_on_obj(insert, adapter)
adapter.iterselect = _wrap_on_obj(iterselect, adapter)
patch_dialect(adapter.dialect)
patch_parser(adapter.parser)
patch_representer(adapter.representer)


def patch_dialect(dialect):
Expand All @@ -93,20 +99,22 @@ def patch_dialect(dialect):
dialect.drop_constraint = _wrap_on_obj(_drop_constraint, dialect)


def patch_parser(parser):
def patch_parser(dialect, parser):
parser.registered['reference'] = ParserMethodWrapper(
parser,
_parser_for_type('reference')(_parser_reference).f,
parser._before_registry_['reference']
)
parser.registered['geography'] = ParserMethodWrapper(
parser,
_parser_for_type('geography')(_parser_geo).f
)
parser.registered['geometry'] = ParserMethodWrapper(
parser,
_parser_for_type('geometry')(_parser_geo).f
)
if 'geography' in dialect.types:
parser.registered['geography'] = ParserMethodWrapper(
parser,
_parser_for_type('geography')(_parser_geo).f
)
if 'geometry' in dialect.types:
parser.registered['geometry'] = ParserMethodWrapper(
parser,
_parser_for_type('geometry')(_parser_geo).f
)


def patch_representer(representer):
Expand Down
5 changes: 4 additions & 1 deletion emmett/orm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,10 @@ def __setitem__(self, key, value):

def __getstate__(self):
return {
"__data": self.__dict__.copy(),
"__data": {
key: self.__dict__[key]
for key in set(self.__dict__.keys()) & self._model._fieldset_all
},
"__struct": {
"_concrete": self._concrete,
"_changes": {},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Emmett"
version = "2.4.4"
version = "2.4.5"
description = "The web framework for inventors"
authors = ["Giovanni Barillari <[email protected]>"]
license = "BSD-3-Clause"
Expand Down

0 comments on commit 6b5fa27

Please sign in to comment.