zzh-gavin / vscode-extension-gyctools

This is a tool for generate your code from database table definition.Currently we only support MySQL.
MIT License
4 stars 2 forks source link

无法获得列信息 property.propertyName #3

Closed corpser closed 1 year ago

corpser commented 1 year ago

我在本地使用的过程中,这段代码无法读取到表中的列信息 {% for property in properties %} {% if property.isInBaseModel == false and property.columnName != primaryKey %} private {{ property.propertyType }} {{ property.propertyName }}; {% endif %} {% endfor %}

zzh-gavin commented 1 year ago

代码提交更新到了1.3.2版本,与vscode market 同步了。再试试你说的问题吧

corpser commented 1 year ago

我这边测了下,升级到1.3.2版本后,会强制校验字段的comment。

右下角会提示这个错误 Cannot read properties of undefined (reading 'comment')

zzh-gavin commented 1 year ago

能说一下你的环境么?vscode版本和数据库版本?目前只支持mysql和mssqlserver

corpser commented 1 year ago

vscode: February 2023 (version 1.76) SQLTools: v0.27.1 msyql: 5.7 patella 1.3.1 可以生成文件,但是获取不到列信息。1.3.2 就直接提示 Cannot read properties of undefined (reading 'comment')

zzh-gavin commented 1 year ago

有几个检查的地方: 1、配置文件的"dataBaseName" 需要跟你右键选择的库名一致; 2、检查一下链接的用户是否有读表权限。试试源代码中的SQL看看执行结果: SELECT COLUMN_Name AS 'columnName', DATA_TYPE AS 'dataType', CASE IS_NULLABLE WHEN 'NO' THEN 0 WHEN 'YES' THEN 1 ELSE 0 END AS 'isNullable', COLUMN_COMMENT AS 'comment', CASE EXTRA WHEN 'auto_increment' THEN 1 ELSE 0 END AS 'isAutoIncrement', CASE COLUMN_KEY WHEN 'PRI' THEN 1 ELSE 0 END AS 'isPk', TABLE_NAME AS tableName, TABLE_SCHEMA AS databaseName FROM information_schema.COLUMNS