Skip to content

使用FreeSql.Generator对PgSQL数据库表生成的实体属性位置错乱 #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lzmj opened this issue Jun 9, 2022 · 0 comments
Closed

Comments

@lzmj
Copy link

lzmj commented Jun 9, 2022

FreeSql.Generator版本:3.2.661

如图所示,position 已经排序,并且 输出的 position 非常大,有问题
)NY(8@2M8 T`M ~RG(L${QW

_V)C{P%@RKAU85@VAHYN@GP

上面说明 position 的赋值有问题!!!

如果类似 以下的SQL查询,使用 information_schema.COLUMNS 的 ordinal_position 作为 列 的 position,则将不会出现该问题。

SELECT
	col.table_schema AS SCHEMA_NAME,
	col.ordinal_position,
	col.TABLE_NAME,
	col.COLUMN_NAME,	
	col_description ( C.oid, col.ordinal_position ) AS COMMENT,
	col.udt_name,
	col.character_maximum_length,
	col.is_nullable,
	col.numeric_precision,
	col.numeric_scale	
FROM
	information_schema.COLUMNS AS col
	LEFT JOIN pg_namespace ns ON ns.nspname = col.table_schema
	LEFT JOIN pg_class C ON col.TABLE_NAME = C.relname 
	AND C.relnamespace = ns.oid
	LEFT JOIN pg_attrdef A ON C.oid = A.adrelid 
	AND col.ordinal_position = A.adnum
	LEFT JOIN pg_attribute b ON b.attrelid = C.oid 
	AND b.attname = col.
	COLUMN_NAME LEFT JOIN pg_type et ON et.oid = b.atttypid
	LEFT JOIN pg_collation coll ON coll.oid = b.attcollation
	LEFT JOIN pg_namespace colnsp ON coll.collnamespace = colnsp.oid
	LEFT JOIN pg_type bt ON et.typelem = bt.oid
	LEFT JOIN pg_namespace nbt ON bt.typnamespace = nbt.oid 
WHERE
	col.table_schema = 'public' 
	AND col.TABLE_NAME = '表名'
ORDER BY
	col.table_schema,
	col.TABLE_NAME,
	col.ordinal_position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants