Skip to content

Commit 3e74109

Browse files
committed
fixed PostgreSql f-key bug
1 parent ad8ffe3 commit 3e74109

File tree

4 files changed

+49
-52
lines changed

4 files changed

+49
-52
lines changed

doc/SmartCode.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Build:
5454
IgnorePrefix: 'T_'
5555
Delimiter: '_'
5656
Converter:
57-
Type: Default
57+
Type: Pascal
5858
Paramters: { }
5959
View:
6060
Tokenizer:
@@ -96,15 +96,15 @@ Build:
9696
IgnorePrefix: 'T_'
9797
Delimiter: '_'
9898
Converter:
99-
Type: Default
99+
Type: Pascal
100100
View:
101101
Tokenizer:
102102
Type: Default
103103
Paramters:
104104
IgnorePrefix: 'V_'
105105
Delimiter: '_'
106106
Converter:
107-
Type: Default
107+
Type: Pascal
108108

109109
SqlMap:
110110
Type: Table
@@ -122,20 +122,20 @@ Build:
122122
IgnorePrefix: 'T_'
123123
Delimiter: '_'
124124
Converter:
125-
Type: Default
125+
Type: Pascal
126126
View:
127127
Tokenizer:
128128
Type: Default
129129
Paramters:
130130
IgnorePrefix: 'V_'
131131
Delimiter: '_'
132132
Converter:
133-
Type: Default
133+
Type: Pascal
134134
Column:
135135
Tokenizer:
136136
Type: Default
137137
Paramters:
138138
IgnorePrefix: 'T_'
139139
Delimiter: '_'
140140
Converter:
141-
Type: Default
141+
Type: Pascal

src/SmartCode.CLI/RazorTemplates/Entity.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace @(project.Module)[email protected]
2424
@(this.PadLeft(8)+"///<summary>\r\n")
2525
@(this.PadLeft(8)+$"///{column.Description ?? column.ConvertedName}\r\n")
2626
@(this.PadLeft(8)+"///</summary>\r\n")
27-
@this.PadLeft(8)<text>public</text> <text>@column.LanguageType</text><text>@(column.IsNullable&&column.LanguageType.ToLower()!="string" ? "?" : "")</text> <text>@column.ConvertedName</text> <text>{ get; set; }</text>@("\r\n")
27+
@this.PadLeft(8)<text>public</text> <text>@column.LanguageType</text><text>@(column.IsNullable&&column.LanguageType!="string" ? "?" : "")</text> <text>@column.ConvertedName</text> <text>{ get; set; }</text>@("\r\n")
2828
}
2929
}
3030
}

src/SmartCode.Db/DbTypeConverter/DbTypeMap.xml

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -92,55 +92,52 @@
9292
<DbType Name="timestamp" To="DateTime" />
9393
</Database>
9494
<Database DbProvider="PostgreSql" Language="CSharp">
95-
<DbType Name="image" To="byte[]"/>
9695
<DbType Name="bool" To="bool"/>
97-
<DbType Name="json" To="string"/>
98-
<DbType Name="uuid" To="Guid"/>
99-
<DbType Name="text" To="string"/>
100-
<DbType Name="ntext" To="string"/>
101-
<DbType Name="varchar" To="string"/>
102-
<DbType Name="nvarchar" To="string" />
103-
<DbType Name="varchar2" To="string" />
104-
<DbType Name="nvarchar2" To="string" />
105-
<DbType Name="xml" To="string"/>
106-
<DbType Name="uniqueidentifier" To="Guid"/>
107-
<DbType Name="date" To="DateTime"/>
108-
<DbType Name="smalldatetime" To="DateTime"/>
109-
<DbType Name="datetime" To="DateTime" />
110-
<DbType Name="datetime2" To="DateTime"/>
111-
<DbType Name="time" To="TimeSpan"/>
112-
<DbType Name="datetimeoffset" To="DateTimeOffset"/>
113-
<DbType Name="tinyint" To="byte"/>
114-
<DbType Name="smallint" To="short"/>
115-
<DbType Name="int" To="int"/>
11696
<DbType Name="int2" To="short"/>
11797
<DbType Name="int4" To="int"/>
11898
<DbType Name="int8" To="long"/>
119-
<DbType Name="bigint" To="long"/>
120-
<DbType Name="bit" To="bool" />
121-
<DbType Name="char" To="string" />
122-
<DbType Name="nchar" To="string" />
123-
<DbType Name="uniqueide" To="Guid" />
124-
<DbType Name="numeric" To="decimal" />
125-
<DbType Name="integer" To="int" />
126-
<DbType Name="money" To="decimal" />
127-
<DbType Name="real" To="decimal" />
128-
<DbType Name="blob" To="byte[]" />
129-
<DbType Name="ntext" To="string" />
130-
<DbType Name="single" To="float" />
131-
<DbType Name="smallmoney" To="decimal" />
132-
<DbType Name="decimal" To="decimal" />
133-
<DbType Name="bfile" To="byte[]" />
134-
<DbType Name="float" To="float" />
135-
<DbType Name="uniqueidentifier" To="Guid" />
136-
<DbType Name="text" To="string" />
137-
<DbType Name="binary" To="byte[]" />
138-
<DbType Name="number" To="decimal" />
139-
<DbType Name="varbinary" To="byte[]" />
140-
<DbType Name="boolean" To="bool" />
141-
<DbType Name="long" To="byte[]" />
142-
<DbType Name="longtext" To="string" />
99+
<DbType Name="float4" To="float" />
100+
<DbType Name="float8" To="double" />
101+
<DbType Name="numeric" To="decimal"/>
102+
<DbType Name="money" To="decimal"/>
103+
<DbType Name="text" To="string"/>
104+
<DbType Name="varchar" To="string"/>
105+
<DbType Name="bpchar" To="string"/>
106+
<DbType Name="citext" To="string" />
107+
<DbType Name="json" To="string" />
108+
<DbType Name="jsonb" To="string" />
109+
<DbType Name="xml" To="string"/>
110+
<DbType Name="point" To="NpgsqlPoint"/>
111+
<DbType Name="lseg" To="NpgsqlLSeg"/>
112+
<DbType Name="path" To="NpgsqlPath"/>
113+
<DbType Name="polygon" To="NpgsqlPolygon" />
114+
<DbType Name="line" To="NpgsqlLine"/>
115+
<DbType Name="circle" To="NpgsqlCircle"/>
116+
<DbType Name="box" To="NpgsqlBox"/>
117+
<DbType Name="bit(1)" To="bool"/>
118+
<DbType Name="bit(n)" To="BitArray"/>
119+
<DbType Name="varbit" To="BitArray"/>
120+
<!--<DbType Name="hstore" To="<![CDATA[ IDictionary<string, string>]]>"/>-->
121+
<DbType Name="uuid" To="Guid" />
122+
<DbType Name="cidr" To="NpgsqlInet" />
123+
<DbType Name="inet" To="IPAddress" />
124+
<DbType Name="macaddr" To="PhysicalAddress" />
125+
<DbType Name="tsquery" To="NpgsqlTsQuery" />
126+
<DbType Name="tsvector" To="NpgsqlTsVector" />
127+
<DbType Name="date" To="DateTime" />
128+
<DbType Name="interval" To="TimeSpan" />
143129
<DbType Name="timestamp" To="DateTime" />
130+
<DbType Name="timestamptz" To="DateTime" />
131+
<DbType Name="time" To="TimeSpan" />
132+
<DbType Name="timetz" To="DateTimeOffset" />
133+
<DbType Name="bytea" To="byte[]" />
134+
<DbType Name="oid" To="uint" />
135+
<DbType Name="xid" To="uint" />
136+
<DbType Name="cid" To="uint" />
137+
<DbType Name="oidvector" To="uint[]" />
138+
<DbType Name="char" To="byte" />
139+
<DbType Name="geometry" To="PostgisGeometry" />
140+
<DbType Name="record" To="object[]" />
144141
</Database>
145142
<Database DbProvider="Oracle" Language="CSharp">
146143
<DbType Name="image" To="byte[]"/>

src/SmartCode.Db/Maps/Database-PostgreSql.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
From pg_class c
4343
Left Join pg_attribute a on a.attrelid=c.oid
4444
Left Join pg_type t on t.oid=a.atttypid
45-
Left Join pg_constraint cs on cs.conrelid=c.oid
45+
Left Join pg_constraint cs on cs.conrelid=c.oid and cs.contype='p'
4646
Where a.attnum>0 and c.relname=@TableName
4747
</Statement>
4848
</Statements>

0 commit comments

Comments
 (0)