Unnecessary comma in CREATE TABLE statement

Description

I develop NHibernate Driver for DBMS Linter SQL and found a problem in file Nhibernate\Mapping\Table.cs. The problem is in the following code:
foreach (UniqueKey uk in UniqueKeyIterator)
{
buf.Append(',').Append(uk.SqlConstraintString(dialect));
}
This code produces unnecessary comma in CREATE TABLE statement if dialect doesn't support not null unique constraints. For example, in test Nhibernate.Test.Component.Basic.ComponentWithUniqueConstraintTests.CanBePersistedWithUniqueValues we have the following query:
create table Employee (Id BIGINT not null, Name VARCHAR(255) null, Dob DATE null, HireDate DATE null, primary key (Id),);
I suggest that we check property dialect.SupportsNotNullUnique before running foreach loop. Something like this:
if (dialect.SupportsNotNullUnique)
{
foreach (UniqueKey uk in UniqueKeyIterator)
{
buf.Append(',').Append(uk.SqlConstraintString(dialect));
}
}

Environment

Windows 7 x64 DBMS Linter SQL

Activity

Show:

Alex Zaytsev 
April 11, 2018 at 1:28 PM

Moved here

Alexey Lesnyh 
January 20, 2015 at 1:37 PM

Ricardo Peres 
January 20, 2015 at 1:36 PM

Can you submit a pull request with your solution and a unit test? It makes it easier to test and integrate.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created January 20, 2015 at 1:25 PM
Updated April 11, 2018 at 1:28 PM
Resolved April 11, 2018 at 1:19 PM
Who's Looking?