From d14fa94a36c562c0bea46aeb4f4206352b35eb2d Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 16 Nov 2011 07:47:00 +0000 Subject: [PATCH] Sql: REFERENCES in .sch now can be preset by Sql (prerequisite for introspection) git-svn-id: svn://ultimatepp.org/upp/trunk@4174 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/MSSQL/MSSQLSchema.h | 3 +++ uppsrc/MySql/MySqlSchema.h | 3 +++ uppsrc/Oracle/OracleSchema.h | 3 +++ uppsrc/PostgreSQL/PostgreSQLSchema.h | 3 +++ uppsrc/ide/UppWspc.cpp | 2 +- uppsrc/plugin/sqlite3/Sqlite3Schema.h | 11 +++++++++++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/uppsrc/MSSQL/MSSQLSchema.h b/uppsrc/MSSQL/MSSQLSchema.h index 365891a17..d3f515431 100644 --- a/uppsrc/MSSQL/MSSQLSchema.h +++ b/uppsrc/MSSQL/MSSQLSchema.h @@ -59,9 +59,12 @@ "drop index IDX_@x;") #define UNIQUE ATTRIBUTE("create unique index UNQ_@x on @t(@c);", \ "drop index UNQ_@x;") + +#ifndef REFERENCES #define REFERENCES(x) ATTRIBUTE("alter table @t add constraint FK_@x foreign key "\ "(@c) references @s" #x ";",\ "alter table @t drop constraint FK_@x;") +#endif #define TIMESTAMP(ts) SCHEMA("-- " ts "\n\n", NULL) diff --git a/uppsrc/MySql/MySqlSchema.h b/uppsrc/MySql/MySqlSchema.h index a3e1299a4..ba37c673e 100644 --- a/uppsrc/MySql/MySqlSchema.h +++ b/uppsrc/MySql/MySqlSchema.h @@ -46,9 +46,12 @@ "alter table @t drop index IDX_@x;") #define UNIQUE ATTRIBUTE("alter table @t add unique UNQ_@x (@c);", \ "alter table @t drop index UNQ_@x;") + +#ifndef REFERENCES #define REFERENCES(x) ATTRIBUTE("alter table @t add (constraint FK_@x foreign key "\ "(@c) references " #x ");",\ "alter table @t drop constraint FK_@x;") +#endif #define TIMESTAMP(ts) SCHEMA("-- " ts "\n\n", NULL) diff --git a/uppsrc/Oracle/OracleSchema.h b/uppsrc/Oracle/OracleSchema.h index e64a22a76..0bf57d07f 100644 --- a/uppsrc/Oracle/OracleSchema.h +++ b/uppsrc/Oracle/OracleSchema.h @@ -62,16 +62,19 @@ "(@c) references " #x ");",\ "alter table @t drop constraint FK_@x;") #endif + #ifndef REFERENCES_CASCADE #define REFERENCES_CASCADE(x) ATTRIBUTE("alter table @t add (constraint FK_@x foreign key "\ "(@c) references " #x " on delete cascade);",\ "alter table @t drop constraint FK_@x;") #endif + #ifndef REFERENCES_ #define REFERENCES_(n, x) ATTRIBUTE("alter table @t add (constraint FK_@x$" #n " foreign key "\ "(@c) references " #x ");",\ "alter table @t drop constraint FK_@x$" #n ";") #endif + #ifndef REFERENCES_CASCADE_ #define REFERENCES_CASCADE_(n, x) ATTRIBUTE("alter table @t add (constraint FK_@x$" #n " foreign key "\ "(@c) references " #x " on delete cascade);",\ diff --git a/uppsrc/PostgreSQL/PostgreSQLSchema.h b/uppsrc/PostgreSQL/PostgreSQLSchema.h index 161ff44c2..d235ef66d 100644 --- a/uppsrc/PostgreSQL/PostgreSQLSchema.h +++ b/uppsrc/PostgreSQL/PostgreSQLSchema.h @@ -82,16 +82,19 @@ "(@c) references " #x ";",\ "alter table @t drop constraint FK_@x;") #endif + #ifndef REFERENCES_CASCADE #define REFERENCES_CASCADE(x) ATTRIBUTE("alter table @t add constraint FK_@x foreign key "\ "(@c) references " #x " on delete cascade;",\ "alter table @t drop constraint FK_@x;") #endif + #ifndef REFERENCES_ #define REFERENCES_(n, x) ATTRIBUTE("alter table @t add constraint FK_@x$" #n " foreign key "\ "(@c) references " #x ";",\ "alter table @t drop constraint FK_@x$" #n ";") #endif + #ifndef REFERENCES_CASCADE_ #define REFERENCES_CASCADE_(n, x) ATTRIBUTE("alter table @t add constraint FK_@x$" #n " foreign key "\ "(@c) references " #x " on delete cascade;",\ diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index b4be9bd89..891b407e9 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -175,7 +175,7 @@ void WorkspaceWork::SavePackage() for(int i = 0; i < actual.GetCount(); i++) { String f = actual[i]; if(ToLower(GetFileExt(f)) == ".icpp") - init << "#define BLITZ_INDEX__ " << "F" + MD5String(init + f) << "\r\n" + init << "#define BLITZ_INDEX__ " << "F" << MD5String(init + f) << "\r\n" << "#include \"" << f << "\"\r\n" << "#undef BLITZ_INDEX__\r\n"; } diff --git a/uppsrc/plugin/sqlite3/Sqlite3Schema.h b/uppsrc/plugin/sqlite3/Sqlite3Schema.h index b9f76409c..d1b8ea649 100644 --- a/uppsrc/plugin/sqlite3/Sqlite3Schema.h +++ b/uppsrc/plugin/sqlite3/Sqlite3Schema.h @@ -48,10 +48,21 @@ #define UNIQUE ATTRIBUTE("create unique index IDX_@x on @t(@c);", \ "drop index IDX_@x;") +#ifndef REFERENCES #define REFERENCES(x) +#endif + +#ifndef REFERENCES_CASCADE #define REFERENCES_CASCADE(x) +#endif + +#ifndef REFERENCES_ #define REFERENCES_(n, x) +#endif + +#ifndef REFERENCES_CASCADE_ #define REFERENCES_CASCADE_(n, x) +#endif #define DUAL_PRIMARY_KEY(k1, k2) INLINE_ATTRIBUTE(", primary key (" #k1 ", " #k2 ")")