Skip to content
Snippets Groups Projects
Commit d01d408a authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

SqlBuilder only add 'from' when there is a select-part

parent fcf888c1
No related branches found
No related tags found
No related merge requests found
......@@ -1054,7 +1054,7 @@ SqlBuilder.prototype.tableName = function (pTable)
*/
SqlBuilder.prototype.from = function(pTable, pTableAlias)
{
this._from = SqlBuilder._getStatement(pTable, "from", pTableAlias, false, (pTableAlias ? false : true));
this._from = SqlBuilder._getStatement(pTable, "", pTableAlias, false, (pTableAlias ? false : true));
if (typeof(pTable) === "string")
this._tableName = pTable;
return this;
......@@ -2193,10 +2193,7 @@ SqlBuilder.prototype.whereWasCalled = function() {
*/
SqlBuilder.prototype.isFullSelect = function()
{
if (!this._select || !this._from)
return false;
return true;
return !(!this._select || !this._from);
}
/**
......@@ -2375,9 +2372,14 @@ SqlBuilder.prototype.buildCondition = function()
SqlBuilder.prototype.build = function(pDefaultConditionIfNone)
{
var wherePrefix = "";
var fromObj = this._from;
if (this.isFullSelect())
{
fromObj = {
sqlStorage: "from " + this._from.sqlStorage,
preparedValues: this._from.preparedValues
};
if (this._where.sqlStorage)
wherePrefix = "where ";
}
......@@ -2390,11 +2392,11 @@ SqlBuilder.prototype.build = function(pDefaultConditionIfNone)
var whereObj = {
sqlStorage : wherePrefix + whereSql,
preparedValues : this._where.preparedValues
}
};
var allParts = [
this._select,
this._from,
fromObj
].concat(this._joins).concat([
whereObj,
this._groupBy,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment