Open SlavaUtesinov opened 3 years ago
Thank you for your analysis, you found a valid need.
maxLength
attribute to the model, so we know what type to use better, it is also in odata standardmaxLength
support usage https://github.com/pofider/node-odata-to-sqluntil we mark all properties, you can just use this hack in oracle store extension
reporter.documentStore.on('before-init', () => {
function processType (typeDef) {
for (const propName in typeDef) {
const propDef = typeDef[propName]
if (propDef.document && propDef.type === 'Edm.String') {
propDef.maxLength = 'max'
}
}
}
for (const typeName in reporter.documentStore.model.complexTypes) {
processType(reporter.documentStore.model.complexTypes[typeName])
}
for (const typeName in reporter.documentStore.model.entityTypes) {
processType(reporter.documentStore.model.entityTypes[typeName])
}
})
This will update the model and set to entity properties maxLength
based on the currently used document
attribute.
executeQuery
function, (you now have the entitySet in opts)Please let me know if you are missing something to continue further. Thank you for your work on oracle-store.
@pofider
I have added the following to the oracle-store pull request: https://github.com/jsreport/jsreport-oracle-store/pull/1/commits/8f08011593a4e4cb482a85bf53c9f83d22edc739
Is this the way to go?
Is this also correct behavior with binary type, since its also a clob? Can you point me to a plugin where binary is used so I can test it?
The following type should also use clob:
@pofider instead of using maxLength, is it maybe better to define a new type like "Edm.StringMax"?
Currently in oracle-store-extension there is now this:
if (propDef.type === 'Edm.String' && propDef.document) {
propDef.maxLength = 'max'
} else if (propDef.type === 'Edm.String' && typeName === 'SettingType' && propName === 'value') {
propDef.maxLength = 'max'
}
I think its more maintainable and less error prone to use the Edm.StringMax when defining the model
I created on my own draft of
jsreport-oracle-store
and when I tried to test it withjsreport
I immediately faced a problem at stage of creating sample templates ("sample-template": { "createSamples": true }
). The reason is a type selected forEdm.String
at case of oracle database isvarchar2(4000)
(oracle.js). I know, it is restriction of oracle, but on the other hand it is obviously not enough (for example, you usevarchar(max)
for mssql) even for your own templates. Probably you should useCLOB
type for unlimited string content, but at this case you also have to construct another sql scripts for them, because scripts likewhere clobColumnName = 'value'
is not supported forCLOB
, moreover possibly some castings to and fromCLOB
type also have to be done.