From 379a8b38220370516a67fe7e64786e82b9056184 Mon Sep 17 00:00:00 2001 From: EXP <289065406@qq.com> Date: Thu, 19 Sep 2024 08:27:42 +0800 Subject: [PATCH] =?UTF-8?q?1.1.5=20=E4=BF=AE=E5=A4=8D=E5=88=97=E6=98=8E?= =?UTF-8?q?=E6=97=A0=E7=B1=BB=E5=9E=8B=E5=89=8D=E7=BC=80=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E4=B8=8E=E5=8F=98=E9=87=8F=E5=90=8D=E5=86=B2=E7=AA=81=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- src/pypdm/_pdm.py | 10 ++++++++-- src/pypdm/assist/cfg.py | 2 +- src/pypdm/builder.py | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index a62c1a4..8518c37 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ # For a discussion on single-sourcing the version across setup.py and the # project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.1.4', # Required + version='1.1.5', # Required # This is a one-line description or tagline of what your project does. This # corresponds to the "Summary" metadata field: diff --git a/src/pypdm/_pdm.py b/src/pypdm/_pdm.py index 29ef68f..b7f7bc3 100644 --- a/src/pypdm/_pdm.py +++ b/src/pypdm/_pdm.py @@ -86,7 +86,7 @@ def _to_beans(self, table_name, columns) : placeholders = { '{table_name}': table_name, '{TableName}': self._to_camel(table_name), - '{columns}': '\n'.join(list(map((lambda col: '\t%s = "%s"' % (col, col)), columns))), + '{columns}': '\n'.join(list(map((lambda col: '\t%s = "%s"' % (self._to_colname(col), col)), columns))), '{variables}': '\n'.join(list(map((lambda col: '\t\tself.%s = None' % col), variables))), '{params}': '\n'.join(list(('\t\t\tself.%s,' % col) for col in variables[1:])), '{kvs}': '\n'.join(list(map(self._to_kv, columns))) @@ -102,12 +102,18 @@ def _to_camel(self, underline) : return camel + # 列变量添加前缀 c_, 避免与类型变量重名 + def _to_colname(self, col) : + return f'c_{col}' + + + # 去掉表名前的类型定义(现在已过时) def _to_var(self, col) : return re.sub(r'^[a-zA-Z]_', '', col) def _to_kv(self, col) : - return '\t\t\t\t"\t%s = %s" % (self.' + col + ', self.' + self._to_var(col) + '),' + return '\t\t\t\t"\t%s = %s" % (self.' + self._to_colname(col) + ', self.' + self._to_var(col) + '),' def _to_daos(self, table_name, columns) : diff --git a/src/pypdm/assist/cfg.py b/src/pypdm/assist/cfg.py index 41ba581..315d228 100644 --- a/src/pypdm/assist/cfg.py +++ b/src/pypdm/assist/cfg.py @@ -59,8 +59,8 @@ def __repr__(self) : # DAO: @{table_name} # ------------------------------- -from ..bean.@{table_name} import @{TableName} from pypdm.dao._base import BaseDao +from bean.@{table_name} import @{TableName} class @{TableName}Dao(BaseDao) : diff --git a/src/pypdm/builder.py b/src/pypdm/builder.py index 2df9168..3472e37 100644 --- a/src/pypdm/builder.py +++ b/src/pypdm/builder.py @@ -57,7 +57,7 @@ def build( :param pdm_pkg: 期望生成 PDM 文件的包路径 :param table_whitelist: 要生成哪些表的 PDM 文件(默认所有表) :param table_blacklist: 不生成哪些表的 PDM 文件 - :param to_log: 是否启用内部日志(此参数在 1.1.3 之后已失效) + :param to_log: 是否启用内部日志(此参数在 1.1.3 之后已失效,强制使用) :return: ''' paths = []