knex/src/dialects/oracle/formatter.js

33 lines
787 B
JavaScript
Raw Normal View History

2016-03-02 17:07:05 +01:00
import inherits from 'inherits';
import Formatter from '../../formatter';
import { ReturningHelper } from './utils';
2016-03-02 17:07:05 +01:00
import { assign } from 'lodash'
2016-03-02 17:07:05 +01:00
function Oracle_Formatter(client) {
Formatter.call(this, client)
}
inherits(Oracle_Formatter, Formatter)
assign(Oracle_Formatter.prototype, {
alias(first, second) {
2016-03-02 17:07:05 +01:00
return first + ' ' + second;
},
parameter(value, notSetValue) {
2016-03-02 17:07:05 +01:00
// Returning helper uses always ROWID as string
if (value instanceof ReturningHelper && this.client.driver) {
value = new this.client.driver.OutParam(this.client.driver.OCCISTRING)
}
else if (typeof value === 'boolean') {
value = value ? 1 : 0
}
return Formatter.prototype.parameter.call(this, value, notSetValue)
}
})
export default Oracle_Formatter