Permalink
Browse files

Put back the IF NOT EXISTS in the INDEX generation. This will break the

MySQL back-end, but I'll have to find another solution for that.
  • Loading branch information...
1 parent d36d08f commit fa108805284e1894c9a3af272b982cdb41f28773 @zefhemel zefhemel committed Aug 12, 2010
Showing with 12 additions and 8 deletions.
  1. +11 −8 persistence.js
  2. +1 −0 test/test.persistence.html
View
@@ -282,8 +282,8 @@ persistence.get = function(arg1, arg2) {
otherMeta = meta.hasOne[rel].type.meta;
rowDef += rel + " VARCHAR(32), ";
queries.push( [
- //"CREATE INDEX IF NOT EXISTS `" + meta.name + "_" + rel + "_" + otherMeta.name
- "CREATE INDEX `" + meta.name + "_" + rel + "_" + otherMeta.name
+ "CREATE INDEX IF NOT EXISTS `" + meta.name + "_" + rel + "_" + otherMeta.name
+ //"CREATE INDEX `" + meta.name + "_" + rel + "_" + otherMeta.name
+ "` ON `" + meta.name + "` (`" + rel + "`)", null ]);
}
}
@@ -293,12 +293,12 @@ persistence.get = function(arg1, arg2) {
if (!persistence.generatedTables[tableName]) {
var otherMeta = meta.hasMany[rel].type.meta;
queries.push( [
- //"CREATE INDEX IF NOT EXISTS `" + tableName + "_" + meta.name + "_" + rel + "` ON `"
- "CREATE INDEX `" + tableName + "_" + meta.name + "_" + rel + "` ON `"
+ "CREATE INDEX IF NOT EXISTS `" + tableName + "_" + meta.name + "_" + rel + "` ON `"
+ //"CREATE INDEX `" + tableName + "_" + meta.name + "_" + rel + "` ON `"
+ tableName + "` (`" + meta.name + "_" + rel + "`)", null ]);
queries.push( [
- //"CREATE INDEX IF NOT EXISTS `" + tableName + "_" + otherMeta.name + "_"
- "CREATE INDEX `" + tableName + "_" + otherMeta.name + "_"
+ "CREATE INDEX IF NOT EXISTS `" + tableName + "_" + otherMeta.name + "_"
+ //"CREATE INDEX `" + tableName + "_" + otherMeta.name + "_"
+ meta.hasMany[rel].inverseProperty + "` ON `" + tableName + "` (`"
+ otherMeta.name + "_" + meta.hasMany[rel].inverseProperty + "`)", null ]);
queries.push( [
@@ -2179,8 +2179,11 @@ persistence.get = function(arg1, arg2) {
}());
try {
- exports.persistence = persistence;
-} catch(e) {}
+ if(exports) {
+ exports.persistence = persistence;
+ }
+} catch(e) {
+}
// ArgSpec.js library: http://github.com/zefhemel/argspecjs
@@ -6,6 +6,7 @@
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="qunit/qunit.js"></script>
+ <script src="http://code.google.com/apis/gears/gears_init.js"></script>
<script src="../persistence.js" type="application/javascript"></script>
<script type="text/javascript" src='util.js'></script>
<script type="text/javascript" src='test.persistence.js'></script>

0 comments on commit fa10880

Please sign in to comment.