Skip to content

Commit

Permalink
Merge pull request C2FO#48 from doug-martin/master
Browse files Browse the repository at this point in the history
v0.1.1
  • Loading branch information
doug-martin committed Aug 29, 2012
2 parents 029379a + 84004ce commit 055b81a
Show file tree
Hide file tree
Showing 14 changed files with 7,555 additions and 7,282 deletions.
8 changes: 8 additions & 0 deletions History.md
@@ -1,3 +1,11 @@
#0.1.1 / 2012-08-29
* new patio.Dataset features
* #sourceList - get all sources as identifiers
* #joinSourceList - get all join sources
* #hasSelectSource - returns true if there are not any select sources (i.e select *)
* #seleIfNoSource - add the selects if there is not currently a select
* Fixed issue with patio.Model#_setFromDb where values not in the models table columns would be in accesible, (i.e a join with a model would not show the join columns)
* updated docs
#0.1.0 / 2012-08-25
* Added custom getters (mbenedettini)
* Added Validator plugin for models
Expand Down
6,856 changes: 3,453 additions & 3,403 deletions docs-md/coverage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs-md/querying.md
Expand Up @@ -265,7 +265,7 @@ If there are multiple arguments in the hash, the filters are `AND`ed together:
```
//SELECT * FROM user WHERE id IN (1, 2, 3) AND name ~ 'Bo$'
User.filter({id : [1,2,3], name : /Bo$/});
``
```

This works the same as if you used two separate filter calls:

Expand Down
6,856 changes: 3,453 additions & 3,403 deletions docs/coverage.html

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions docs/patio.html
Expand Up @@ -959,8 +959,10 @@ <h3>
<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (opts){
comb.logger.configure();
LOGGER.level = &quot;info&quot;;
comb.logger.configure(opts);
if (!opts) {
LOGGER.level = &quot;info&quot;;
}

}
</pre>
Expand Down
152 changes: 119 additions & 33 deletions docs/patio_Dataset.html
Expand Up @@ -2624,6 +2624,20 @@

</a></li>

<li><a href="./patio_Dataset.html#selectIfNoSource">


<span class="label label-label">F</span>



<span class="label label-success">P</span>


selectIfNoSource

</a></li>

<li><a href="./patio_Dataset.html#selectMap">


Expand Down Expand Up @@ -3298,16 +3312,19 @@ <h4>Actions</h4>

}</code></td><td></td><tr><tr><td>firstSourceAlias</td><td>String</td><td></td><td><p>The first source (primary table) for this dataset. If the table is aliased, returns the aliased name. throws a {patio.DatasetError} tf the dataset doesn&#39;t have a table. <pre class="code"> DB.from(&quot;table&quot;).firstSourceAlias; //=&gt; &quot;table&quot; DB.from(&quot;table___t&quot;).firstSourceAlias; //=&gt; &quot;t&quot; </pre></p>
</td><tr><tr><td>firstSourceTable</td><td>String</td><td></td><td><p>The first source (primary table) for this dataset. If the dataset doesn&#39;t have a table, raises a <a href='./patio_erros_DatasetError.html#'> patio.erros.DatasetError</a>. <pre class="code"> DB.from(&quot;table&quot;).firstSourceTable; //=&gt; &quot;table&quot; DB.from(&quot;table___t&quot;).firstSourceTable; //=&gt; &quot;t&quot; </pre></p>
</td><tr><tr><td>hasSelectSource</td><td>Boolean</td><td></td><td><p>true if this dataset already has a select sources.</p>
</td><tr><tr><td>identifierInputMethod</td><td>String</td><td></td><td><p>this is the method that will be called on each identifier returned from the database. This value will be defaulted to whatever the identifierInputMethod is on the database used in initialization.</p>
</td><tr><tr><td>identifierOutputMethod</td><td>String</td><td></td><td><p>this is the method that will be called on each identifier sent to the database. This value will be defaulted to whatever the identifierOutputMethod is on the database used in initialization.</p>
</td><tr><tr><td>isSimpleSelectAll</td><td>Boolean</td><td></td><td><p>Returns true if this dataset is a simple SELECT * FROM {table}, otherwise false. <pre class="code"> DB.from(&quot;items&quot;).isSimpleSelectAll; //=&gt; true DB.from(&quot;items&quot;).filter({a : 1}).isSimpleSelectAll; //=&gt; false </pre></p>
</td><tr><tr><td>joinSourceList</td><td>patio.sql.Identifier[]</td><td><code>[]</code></td><td><p>a list of join sources</p>
</td><tr><tr><td>providesAccurateRowsMatched</td><td>boolean</td><td><code>true</code></td><td><p>Whether this dataset will provide accurate number of rows matched for
delete and update statements. Accurate in this case is the number of
rows matched by the dataset&#39;s filter.</p>
</td><tr><tr><td>quoteIdentifiers</td><td>boolean</td><td><code>true</code></td><td><p>Whether this dataset quotes identifiers.</p>
</td><tr><tr><td>requiresSqlStandardDate</td><td>boolean</td><td><code>false</code></td><td><p>Whether the dataset requires SQL standard datetimes (false by default,
as most allow strings with ISO 8601 format).</p>
</td><tr><tr><td>rowCb</td><td>Function</td><td></td><td><p>callback to be invoked for each row returned from the database. the return value will be used as the result of query. The rowCb can also return a promise, The resolved value of the promise will be used as result.</p>
</td><tr><tr><td>sourceList</td><td>patio.sql.Identifier[]</td><td><code>[]</code></td><td><p>a list of sources for this dataset.</p>
</td><tr><tr><td>supportsCte</td><td>boolean</td><td><code>true</code></td><td><p>Whether the dataset supports common table expressions (the WITH clause).</p>
</td><tr><tr><td>supportsDistinctOn</td><td>boolean</td><td><code>false</code></td><td><p>Whether the dataset supports the DISTINCT ON clause, false by default.</p>
</td><tr><tr><td>supportsIntersectExcept</td><td>boolean</td><td><code>true</code></td><td><p>Whether the dataset supports the INTERSECT and EXCEPT compound operations, true by default.</p>
Expand Down Expand Up @@ -4297,9 +4314,9 @@ <h3>
<pre class="prettyprint linenums lang-js">
function (joinType){
return (joinType || &quot;&quot;).replace(/([a-z]+)|([A-Z][a-z]+)/g,
function (m) {
return m.toUpperCase() + &quot; &quot;;
}
function (m) {
return m.toUpperCase() + &quot; &quot;;
}
).trimRight() + &quot; JOIN&quot;;

}
Expand Down Expand Up @@ -4886,10 +4903,10 @@ <h3>
var table = parts[0], column = parts[1], alias = parts[2];
if (!alias) {
return column &amp;&amp; table ? this._literalExpression(QualifiedIdentifier.fromArgs([table, column])) : &quot;&#x27;&quot;
+ v.replace(/\\/g, &quot;\\\\&quot;).replace(/&#x27;/g, &quot;&#x27;&#x27;&quot;) + &quot;&#x27;&quot;
+ v.replace(/\\/g, &quot;\\\\&quot;).replace(/&#x27;/g, &quot;&#x27;&#x27;&quot;) + &quot;&#x27;&quot;
} else {
return this.literal(new AliasedExpression(column
&amp;&amp; table ? QualifiedIdentifier.fromArgs([table, column]) : new Identifier(column), alias));
&amp;&amp; table ? QualifiedIdentifier.fromArgs([table, column]) : new Identifier(column), alias));
}

}
Expand Down Expand Up @@ -5151,7 +5168,7 @@ <h3>
return new QualifiedIdentifier(table, e);
} else if (isInstanceOf(e, OrderedExpression)) {
return new OrderedExpression(this._qualifiedExpression(e.expression, table), e.descending,
{nulls:e.nulls});
{nulls:e.nulls});
} else if (isInstanceOf(e, AliasedExpression)) {
return new AliasedExpression(this._qualifiedExpression(e.expression, table), e.alias);
} else if (isInstanceOf(e, CaseExpression)) {
Expand Down Expand Up @@ -5829,9 +5846,9 @@ <h3>
throw new QueryError(&quot;No source specified for the query&quot;);
}
return &quot; &quot; + source.map(
function (s) {
return this.__tableRef(s);
}, this).join(this._static.COMMA_SEPARATOR);
function (s) {
return this.__tableRef(s);
}, this).join(this._static.COMMA_SEPARATOR);

}
</pre>
Expand Down Expand Up @@ -7091,8 +7108,8 @@ <h3>
return this.complexExpressionSql(&quot;EQ&quot;, args);
} else {
return this.complexExpressionSql(&quot;OR&quot;,
[BooleanExpression.fromArgs([&quot;NEQ&quot;].concat(args)), new BooleanExpression(&quot;IS&quot;, args[0],
null)]);
[BooleanExpression.fromArgs([&quot;NEQ&quot;].concat(args)), new BooleanExpression(&quot;IS&quot;, args[0],
null)]);
}
} else if ([&quot;IN&quot;, &quot;NOTIN&quot;].indexOf(op) != -1) {
var cols = args[0], vals = args[1], colArray = isArray(cols), valArray = false, emptyValArray = false;
Expand Down Expand Up @@ -7121,8 +7138,8 @@ <h3>
//literal so that if values is an array of two element arrays, it
//will be treated as a value list instead of a condition specifier.
return format(&quot;(%s %s %s)&quot;, isString(cols) ? cols : this.literal(cols),
ComplexExpression.IN_OPERATORS[op],
valArray ? this._arraySql(vals) : this.literal(vals));
ComplexExpression.IN_OPERATORS[op],
valArray ? this._arraySql(vals) : this.literal(vals));
}
}
else {
Expand All @@ -7136,13 +7153,13 @@ <h3>
}
} else {
return format(&quot;(%s %s %s)&quot;, isString(cols) ? cols : this.literal(cols),
ComplexExpression.IN_OPERATORS[op], this.literal(vals));
ComplexExpression.IN_OPERATORS[op], this.literal(vals));
}
}
} else if ((newOp = this._static.TWO_ARITY_OPERATORS[op]) != null) {
var l = args[0];
return format(&quot;(%s %s %s)&quot;, isString(l) ? l : this.literal(l), newOp,
this.literal(args[1]));
this.literal(args[1]));
} else if ((newOp = this._static.N_ARITY_OPERATORS[op]) != null) {
return string.format(&quot;(%s)&quot;, args.map(this.literal, this).join(&quot; &quot; + newOp + &quot; &quot;));
} else if (op == &quot;NOT&quot;) {
Expand Down Expand Up @@ -9529,12 +9546,12 @@ <h3>
var i = this.__identifierInputMethod;
v = v.toString(this);
return !isUndefinedOrNull(i) ?
isFunction(v[i]) ?
v[i]() :
isFunction(comb[i]) ?
comb[i](v)
: v
: v;
isFunction(v[i]) ?
v[i]() :
isFunction(comb[i]) ?
comb[i](v)
: v
: v;

}
</pre>
Expand Down Expand Up @@ -10750,7 +10767,7 @@ <h3>
}
var tref = this.__tableRef(table);
return string.format(&quot; %s %s&quot;, this._joinTypeSql(jc.joinType),
tableAlias ? this.__asSql(tref, tableAlias) : tref);
tableAlias ? this.__asSql(tref, tableAlias) : tref);

}
</pre>
Expand Down Expand Up @@ -12767,12 +12784,12 @@ <h3>
(v == &#x27;&#x27; &amp;&amp; (v = &#x27;untitled&#x27;));
var i = this.__identifierOutputMethod;
return !isUndefinedOrNull(i) ?
isFunction(v[i]) ?
v[i]() :
isFunction(comb[i]) ?
comb[i](v)
: v
: v;
isFunction(v[i]) ?
v[i]() :
isFunction(comb[i]) ?
comb[i](v)
: v
: v;

}
</pre>
Expand Down Expand Up @@ -13012,11 +13029,11 @@ <h3>
<pre class="prettyprint linenums lang-js">
function (qcr){
return [qcr.table, qcr.column].map(
function (x) {
return [QualifiedIdentifier, Identifier, String].some(function (c) {
return x instanceof c
}) ? this.literal(x) : this.quoteIdentifier(x)
}, this).join(&#x27;.&#x27;);
function (x) {
return [QualifiedIdentifier, Identifier, String].some(function (c) {
return x instanceof c
}) ? this.literal(x) : this.quoteIdentifier(x)
}, this).join(&#x27;.&#x27;);

}
</pre>
Expand Down Expand Up @@ -14036,6 +14053,75 @@ <h3>



<a name="selectIfNoSource"></a>
<h3>
selectIfNoSource


<span class="label label-label">Function</span>



<span class="label label-success">Public</span>


</h3>

<hr/>
<em>Defined dataset/query.js</em>

<p><p>Selects the columns if only if there is not already select sources.

</p>
</p>

<em>Example</em>
<pre class="prettyprint linenums lang-js">
var ds = DB.from(&quot;items&quot;); //SELECT * FROM items

ds.select(&quot;a&quot;); //SELECT a FROM items;
ds.select(&quot;a&quot;).selectIfNoSource(&quot;a&quot;, &quot;b&quot;). //SELECT a FROM items;
ds.selectIfNoSource(&quot;a&quot;, &quot;b&quot;). //SELECT a, b FROM items;
</pre>


<em>Arguments</em>
<ul>

<li> <em>cols</em> : <p>columns to select if there is not already select sources.</p>
</li>

</ul>


<em>Returns</em>
<ul>

<li> <code>patio.Dataset</code> <p>a cloned dataset with the appropriate select sources.</p>
</li>

</ul>




<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (cols){
var ret;
if (!this.hasSelectSource) {
ret = this.select.apply(this, arguments);
} else {
ret = this.mergeOptions();
}
return ret;

}
</pre>




<a name="selectMap"></a>
<h3>
selectMap
Expand Down

0 comments on commit 055b81a

Please sign in to comment.