aboutsummaryrefslogtreecommitdiffstats
path: root/trunk
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-03-12 21:16:39 +0100
committerEgil Moeller <egil.moller@freecode.no>2010-03-12 21:16:39 +0100
commitd7578daaf1aeb7c0db0d2cc069f67b870f8bd3e7 (patch)
tree375610d2d57d48a909c67481949a121142d0461f /trunk
parent16b37f7a1f9ff8e559e90261c8f6cd3da46dae49 (diff)
downloadetherpad-d7578daaf1aeb7c0db0d2cc069f67b870f8bd3e7.tar.gz
etherpad-d7578daaf1aeb7c0db0d2cc069f67b870f8bd3e7.tar.xz
etherpad-d7578daaf1aeb7c0db0d2cc069f67b870f8bd3e7.zip
Bugfix for mysql support for anti_tags - I forgot that mysql doesn't support the except sql clause
Diffstat (limited to '')
-rw-r--r--trunk/etherpad/src/etherpad/control/tag/tag_control.js49
1 files changed, 26 insertions, 23 deletions
diff --git a/trunk/etherpad/src/etherpad/control/tag/tag_control.js b/trunk/etherpad/src/etherpad/control/tag/tag_control.js
index e56ee8e..3fe680c 100644
--- a/trunk/etherpad/src/etherpad/control/tag/tag_control.js
+++ b/trunk/etherpad/src/etherpad/control/tag/tag_control.js
@@ -58,6 +58,7 @@ function getQueryToSql(tags, antiTags, querySql) {
var exceptArray = [];
var joinArray = [];
+ var whereArray = [];
var exceptParamArray = [];
var joinParamArray = [];
@@ -68,46 +69,47 @@ function getQueryToSql(tags, antiTags, querySql) {
for (i = 0; i < antiTags.length; i++) {
tag = antiTags[i];
- exceptArray.push(stringFormat('' +
- 'except ' +
- ' select ' +
- ' pt%(n)s.PAD_ID ' +
- ' from ' +
- ' PAD_TAG as pt%(n)s, ' +
- ' TAG as t%(n)s ' +
- ' where ' +
- ' t%(n)s.ID = pt%(n)s.TAG_ID ' +
- ' and t%(n)s.NAME = ? ' +
- '', info));
+ exceptArray.push(
+ stringFormat(
+ 'left join (PAD_TAG as pt%(n)s ' +
+ ' join TAG AS t%(n)s on ' +
+ ' t%(n)s.NAME = ? ' +
+ ' and t%(n)s.ID = pt%(n)s.TAG_ID) on ' +
+ ' pt%(n)s.PAD_ID = p.ID',
+ info));
+ whereArray.push(stringFormat('pt%(n)s.TAG_ID is null', info));
exceptParamArray.push(tag);
info.n += 1;
}
for (i = 0; i < tags.length; i++) {
tag = tags[i];
- joinArray.push(stringFormat('' +
- 'join PAD_TAG as pt%(n)s on ' +
- ' pt%(n)s.PAD_ID = p.ID ' +
- 'join TAG as t%(n)s on ' +
- ' t%(n)s.ID = pt%(n)s.TAG_ID ' +
- ' and t%(n)s.NAME = ? ' +
- '', info));
+ joinArray.push(
+ stringFormat(
+ 'join PAD_TAG as pt%(n)s on ' +
+ ' pt%(n)s.PAD_ID = p.ID ' +
+ 'join TAG as t%(n)s on ' +
+ ' t%(n)s.ID = pt%(n)s.TAG_ID ' +
+ ' and t%(n)s.NAME = ? ',
+ info));
joinParamArray.push(tag);
info.n += 1;
}
info["joins"] = joinArray.join("");
info["excepts"] = exceptArray.join("");
-
+ info["wheres"] = whereArray.length > 0 ? ' where ' + whereArray.join(' ') : '';
+
return {
- sql: stringFormat('' +
+ sql: stringFormat(
'(select ' +
' p.ID ' +
' from ' +
' %(queryTable)s as p ' +
' %(joins)s ' +
- ' %(excepts)s ' +
- ') ' +
- '', info),
+ ' %(excepts)s ' +
+ ' %(wheres)s ' +
+ ') ',
+ info),
params: queryParams.concat(joinParamArray).concat(exceptParamArray)};
}
@@ -187,6 +189,7 @@ function onRequest() {
}
var querySql = getQueryToSql(tags.concat(['public']), antiTags);
+ log.info(querySql.sql);
var queryNewTagsSql = newTagsSql(querySql);
var newTags = sqlobj.executeRaw(queryNewTagsSql.sql, queryNewTagsSql.params);