Skip to content

Commit

Permalink
1.1.5 修复列明无类型前缀时的与变量名冲突错误
Browse files Browse the repository at this point in the history
  • Loading branch information
lyy289065406 committed Sep 19, 2024
1 parent 42a9b81 commit 379a8b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions src/pypdm/_pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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) :
Expand Down
2 changes: 1 addition & 1 deletion src/pypdm/assist/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand Down
2 changes: 1 addition & 1 deletion src/pypdm/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 379a8b3

Please sign in to comment.