Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some issues with Oracle DB #105

Open
buchatsky opened this issue Oct 3, 2014 · 2 comments
Open

Some issues with Oracle DB #105

buchatsky opened this issue Oct 3, 2014 · 2 comments

Comments

@buchatsky
Copy link

  1. sqltree.js: To accept CHAR(1) Oracle "boolean"
    toObject: function (row, result) {
    ...
    if (column.modelColumn.type === type.BOOLEAN && (val !== null)) {
    //val = !!val;
    val = [true, 1].indexOf(val) != -1 || (val.length > 0 && ['T', 't', 'Y', 'y', '1'].indexOf(val[0]) != -1);
    (probably, setter requires changes too, Delphi uses 'F' / 'T' in SetAsBoolean()
  2. driver.js: Oracle does not permit quoted columns in ORDER BY
    getSqlFromSqlTree: function(sqlTree) {
    ...
    //var orderByClause = this.escapeColumnName(orderBy.column.alias) + ' ';
    var orderByClause = orderBy.column.alias + ' ';
  3. model.js: to accept one-to-many relationship in both directions:
    Model.hasMany = function (associatedModel, opts) {
    ...
    if (opts.through) {
    ...
    } else if (opts.createHasOne) {
    var associatedOpts = {};
    associatedOpts.name = opts.hasOneName;
    associatedOpts.foreignKey = opts.foreignKey;
    associatedOpts = this.normalizeHasOneOptions(this, associatedOpts);
    associatedModel.hasOne(this, associatedOpts);
    }
    ...
    Model.hasOne = function (associatedModel, opts) {
    ...
    var foreignKeyPropertyName = inflection.camelize(opts.foreignKey, true);
    if (!this.columns[foreignKeyPropertyName] || !this.columns[foreignKeyPropertyName].foreignKey) {
    this.addColumn(foreignKeyPropertyName, { type: "int", foreignKey: true });
    }
    if (opts.createHasMany) {
        var associatedOpts = {};
        associatedOpts.name = opts.hasManyName;
        associatedOpts.foreignKey = opts.foreignKey;
        associatedOpts = this.normalizeHasManyOptions(this, associatedOpts);
        associatedModel.hasMany(this, associatedOpts);
    }

Good luck!

@buchatsky
Copy link
Author

and I also had to modify executeBaton.cpp in order to accept bool values back to DB:
void ExecuteBaton::CopyValuesToBaton(ExecuteBaton* baton, v8::Localv8::Array* values) {
...
// boolean
else if(val->IsBoolean()) {
bool b = val->IsTrue();
value->type = VALUE_TYPE_STRING;
value->value = new std::string(b ? "T" : "F");
baton->values.push_back(value);
}
It may be another way to specify trueValue and falseValue just in the model, but for me it's enough

@buchatsky
Copy link
Author

...and, in order to accept "unassigned":
// null
if(val->IsNull() || val->IsUndefined()) {
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant