Issue 142 in migratordotnet: SQLIte.NET problems with not null without defaults

18 views
Skip to first unread message

codesite...@google.com

unread,
Mar 11, 2010, 11:47:56 PM3/11/10
to migratordo...@googlegroups.com
Status: New
Owner: ----

New issue 142 by it.adviser.ua: SQLIte.NET problems with not null without
defaults
http://code.google.com/p/migratordotnet/issues/detail?id=142

--- What steps will reproduce the problem?
1. Create SQLite DB. Add table. Create field as not null without default
value.
2. Create migration (try to rename created field).

--- What is the expected output? What do you see instead?
SQLite error.

--- Please use labels and text to provide additional information.
Change SQLiteTransformationProvider.cs as described below (yes, I know,
that this is not best solution.):

public override void RenameColumn(string tableName, string
oldColumnName, string newColumnName)
{
if (ColumnExists(tableName, newColumnName))
throw new MigrationException(String.Format("Table '{0}' has
column named '{1}' already", tableName, newColumnName));

if (ColumnExists(tableName, oldColumnName))
{
string[] columnDefs = GetColumnDefs(tableName);
string columnDef = Array.Find(columnDefs, delegate(string
col) { return ColumnMatch(oldColumnName, col); });

string newColumnDef = columnDef.Replace(oldColumnName,
newColumnName);
//begin deleting not null if not defining default value
if ((newColumnDef.ToLower().Contains(" not null")) &&
(!newColumnDef.ToLower().Contains(" default ")))
{
newColumnDef = newColumnDef.Replace(" not null", "");
newColumnDef = newColumnDef.Replace(" NOT NULL", "");
}
//end deleting not null if not defining default value

AddColumn(tableName, newColumnDef);
ExecuteQuery(String.Format("UPDATE {0} SET {1}={2}",
tableName, newColumnName, oldColumnName));
RemoveColumn(tableName, oldColumnName);
}
}

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

Reply all
Reply to author
Forward
0 new messages