title: Passing function to Knex select method breaks querying
body: <p>The code:</p>
  <pre><code>const knex = require(&quot;../../db/knex&quot;);
  
  module.exports = (request, response) =&gt; {
    knex
      .select((builder) =&gt; {
        const select = request.query.select;
  
        if (select) {
          if (select.constructor === String) {
            builder.select(select);
          } else if (select.constructor === Array) {
            builder.select(...select);
          }
        } else {
          /* Anything that goes here or inside this function, breaks it. */
        }
      })
      .from(&quot;tags&quot;)
      .where((builder) =&gt; {
        const filter = request.query.filter;
  
        if (filter) {
          if (filter.constructor === Object) {
            builder.where(filter);
          } else if (filter.constructor === Array) {
            builder.where(...filter);
          }
        } else {
          builder.clear(&quot;where&quot;);
        }
      })
      .then((result) =&gt; response.json(result))
      .catch((error) =&gt; response.json({ ...error, message: error.stack }));
  };
  </code></pre>
  <p>The full error:</p>
  <pre><code>{
      &quot;length&quot;: 180,
      &quot;name&quot;: &quot;error&quot;,
      &quot;severity&quot;: &quot;ERROR&quot;,
      &quot;code&quot;: &quot;42601&quot;,
      &quot;position&quot;: &quot;16&quot;,
      &quot;file&quot;: &quot;d:\\pginstaller_13.auto\\postgres.windows-x64\\src\\backend\\parser\\parse_target.c&quot;,
      &quot;line&quot;: &quot;1296&quot;,
      &quot;routine&quot;: &quot;ExpandAllTables&quot;,
      &quot;message&quot;: &quot;error: select (select *) from \&quot;tags\&quot; - SELECT * with no tables specified is not valid\n    at Parser.parseErrorMessage (C:\\Users\\Lucas\\Desktop\\Repositories\\projeto-integrador-dh-g1\\node_modules\\pg-protocol\\dist\\parser.js:278:15)\n    at Parser.handlePacket (C:\\Users\\Lucas\\Desktop\\Repositories\\projeto-integrador-dh-g1\\node_modules\\pg-protocol\\dist\\parser.js:126:29)\n    at Parser.parse (C:\\Users\\Lucas\\Desktop\\Repositories\\projeto-integrador-dh-g1\\node_modules\\pg-protocol\\dist\\parser.js:39:38)\n    at Socket.&lt;anonymous&gt; (C:\\Users\\Lucas\\Desktop\\Repositories\\projeto-integrador-dh-g1\\node_modules\\pg-protocol\\dist\\index.js:10:42)\n    at Socket.emit (events.js:315:20)\n    at addChunk (internal/streams/readable.js:309:12)\n    at readableAddChunk (internal/streams/readable.js:284:9)\n    at Socket.Readable.push (internal/streams/readable.js:223:10)\n    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)&quot;
  }
  </code></pre>
  <p>I'm using Express to manage the Node server and Knex to manage the database. In this route, if I remove the function from select, everything works. Tried everything, I can't understand why isn't working. Can anyone help me understand why is it breaking?</p>