datatables.net node.js editor example won't run with oracledb through knex

datatables.net node.js editor example won't run with oracledb through knex

perryjmperryjm Posts: 12Questions: 3Answers: 0

I'm pilot testing datatables for my company, and I'm able to run the editor/node.js example with mysql running locally on my machine. All the examples run just fine at https://localhost:8081/examples.

All things being equal, i modify the db.js file to say the following:

let knex = require('knex');

module.exports = knex({
    client: 'oracledb',

    connection: {
        host: 'oracledev',
        user: 'test',
        password: 'test',
        database: 'orcl'
    }
});

And then attempt to run the example with npm start and i get the following output

DataTables Editor demo - navigate to http://localhost:8081/
TypeError: Cannot read property 'replace' of undefined

the line that comes back right after the server starts is TypeError: Cannot read property 'replace' of undefined And the source of that error i'm finding is very difficult to track down.

Please advise!

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Hi,

    In the index.js file, could you remove:

    process.on( 'unhandledRejection', (reason, p) => {
        console.log( 'Unhandled promise error:  ' + p + reason );
        console.log( 'stack: ' + reason.stack );
    } );
    

    then run the server again. It should then show a full dump with backtrace information which will hopefully help in debugging the issue. Could you show me that output?

    Thanks,
    Allan

  • perryjmperryjm Posts: 12Questions: 3Answers: 0
    edited November 2018

    Removing that snippet from index.js didn't produce new results when starting the server. However, when I attempt to load a page like http://localhost:8081/examples/simple/simple.html I get the following output:

    DataTables Editor demo - navigate to http://localhost:8081/
    TypeError: Cannot read property 'replace' of undefined
    (node:9156) UnhandledPromiseRejectionWarning: Error: ORA-00942: table or view does not exist
    (node:9156) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which
    was not handled with .catch(). (rejection id: 1)
    (node:9156) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    In response to Line 3 At first, this might appear that I haven't added my sample data to oracle. But that isn't so. I followed this tutorial in inserting all the sample data, and it's all committed. But this line does imply knex is (I'm assuming) getting a connection to oracle here.

    Obviously there's a problem somewhere, and I'm a newbie to both datatables and knex, and maybe this is a knex issue more than a datatables issue... it could definitely be an oracle issue. I'm still not sure.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Oracle in combination with NodeJS is one of the combinations we don't currently run through our automated tests, so it is quite possible there is an issue somewhere here.

    What about if you attempt to make a simple database query in the db.js file - something like:

    setTimeout( async function () {
      let res = await knex.select('*').from('...');
      console.log( res );
    }, 1000 );
    

    The setTimeout so we can use async / await and also let the connection setup settle.

    Thanks,
    Allan

  • perryjmperryjm Posts: 12Questions: 3Answers: 0
    edited November 2018

    TypeError: knex.select is not a function is the new error. Heres the full output:

    DataTables Editor demo - navigate to http://localhost:8081/
    TypeError: Cannot read property 'replace' of undefined
    (node:12988) UnhandledPromiseRejectionWarning: TypeError: knex.select is not a function
        at Timeout._onTimeout (C:\Users\Temp\dev\db_editor\db.js:15:24)
        at ontimeout (timers.js:436:11)
        at tryOnTimeout (timers.js:300:5)
        at listOnTimeout (timers.js:263:5)
        at Timer.processTimers (timers.js:223:10)
    (node:12988) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:12988) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit
    code.
    

    I boosted the setTimeout to 10 seconds, just to be sure, same results. Here's the db.js file as it stands now:

    let knex = require('knex');
    
    module.exports = knex({
        client: 'oracledb',
    
        connection: {
            host: 'oracledev',
            user: 'test',
            password: 'test',
            database: 'orcl'
        }
    });
    
    setTimeout( async function () {
      let res = await knex.select('*').from('datatables_demo');
      console.log( res );
    }, 10000 );
    

    Is there any other information I can provide? I know it's difficult to solve a problem when you don't have all the facts/details. We've been using node-oracledb to make connections in the past with success.

  • perryjmperryjm Posts: 12Questions: 3Answers: 0

    Any further word on this?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Sorry for the delay in getting back to you here - I lost track of this thread!

    I realise what I did wrong with the code above. Try:

    let knex = require('knex');
    let db = knex({
        client: 'oracledb',
     
        connection: {
            host: 'oracledev',
            user: 'test',
            password: 'test',
            database: 'orcl'
        }
    });
    
    module.exports = db;
     
    setTimeout( async function () {
      let res = await db.select('*').from('datatables_demo');
      console.log( res );
    }, 1000 );
    

    That I think should at least let it run a query. It will be interesting to know if that executes okay.

    Thanks,
    Allan

  • perryjmperryjm Posts: 12Questions: 3Answers: 0

    Error: ORA-00942: table or view does not exist but the data is in place, not sure what I'm doing wrong to access it. Is there some way I can get some more direct support on this? Again, very interested in datatables editor but need to purchase in the next two weeks. But we're an oracle shop, and if it doesn't work with oracle, we have to go a different direction.

    $ node .
    DataTables Editor demo - navigate to http://localhost:8081/
    TypeError: Cannot read property 'replace' of undefined
    (node:2396) UnhandledPromiseRejectionWarning: Error: ORA-00942: table or view does not exist
    (node:2396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:2396) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    
    select *
    from datatables_demo
    ;
    
    2   Tiger   Nixon   System Architect    t.nixon@datatables.net  Edinburgh   04/25/2011 00:00:00  .....
    3   Garrett Winters Accountant  g.winters@datatables.net    Tokyo   07/25/2011 00:00:00 .....
    4   Ashton  Cox Junior Technical Author a.cox@datatables.net    San Francisco   01/12/2009 00:00:00 .....
    5   Cedric  Kelly   Senior Javascript Developer c.kelly@datatables.net  Edinburgh   03/29/2012 00:00:00 .....
    6   Airi    Satou   Accountant  a.satou@datatables.net  Tokyo   11/28/2008 00:00:00 .....
    7   Brielle Williamson  Integration Specialist  b.williamson@datatables.net New York    12/02/2012 00:00:00 .....
    8   Herrod  Chandler    Sales Assistant h.chandler@datatables.net   San Francisco   08/06/2012 00:00:00 .....
    9   Rhona   Davidson    Integration Specialist  r.davidson@datatables.net   Tokyo   10/14/2010 00:00:00 .....
    10  Colleen Hurst   Javascript Developer    c.hurst@datatables.net  San Francisco   09/15/2009 00:00:00 .....
    11  Sonya   Frost   Software Engineer   s.frost@datatables.net  Edinburgh   12/13/2008 00:00:00 .....
    12  Jena    Gaines  Office Manager  j.gaines@datatables.net London  12/19/2008 00:00:00 .....
    13  Quinn   Flynn   Support Lead    q.flynn@datatables.net  Edinburgh   03/03/2013 00:00:00 .....
    
  • perryjmperryjm Posts: 12Questions: 3Answers: 0

    Allan, thanks again for the support call.

    For the sake of being complete on this forum, what ended up solving the issue was adding a line to db.js.

    wrapIdentifier: (value, origImpl, queryContext) => { return value; }
    

    Knex was putting " double quotation marks around the table name, and oracle didn't like that.

    See this github issue.

This discussion has been closed.