Browse Source

sqlpreprocess enhancements

production
pb 1 year ago
parent
commit
f833a1ea53
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      index.js

+ 7
- 4
index.js View File

noprerequisites : true noprerequisites : true
, cmdFn : function(args){ , cmdFn : function(args){
// PB : TODO -- Load loopback app !!! for ds
var sqlquery = fs.readFileSync(args._[1], { encoding: 'utf8'}) var sqlquery = fs.readFileSync(args._[1], { encoding: 'utf8'})
sqlquery = PATTERNAPI.includesql(sqlquery, path.dirname(args._[1]))
fs.writeFileSync(args._[1] + '.d.sql', sqlquery, { encoding: 'utf8'})
sqlquery = PATTERNAPI.includesql(sqlquery, path.dirname(args._[1])).then(sqlquery => {
sqlquery = " DECLARE @dsql NVARCHAR(MAX) = ' \r\n" + sqlquery.replace(/\'/g,"''")
fs.writeFileSync(args._[1].replace('.sql', '.d.temp.sql'), sqlquery, { encoding: 'utf8'}) // For intermediate processing
fs.writeFileSync(args._[1].replace('.sql', '.d.sql'), sqlquery + "\r\n'" + " EXEC sp_executesql @dsql" , { encoding: 'utf8'}) // Dynamic query output.
return sqlquery
})


return sqlquery


// // PB : TODO -- move to dsql preprocesor // // PB : TODO -- move to dsql preprocesor
// // var sqlquery = 'SET @dsql = @dsql + ' + "'" + ('' + fs.readFileSync(args._[1])).replace(/\'/g,"''") + "'" // // var sqlquery = 'SET @dsql = @dsql + ' + "'" + ('' + fs.readFileSync(args._[1])).replace(/\'/g,"''") + "'"

Loading…
Cancel
Save