New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined max_batch when using knexSnakeCaseWrappers (Objection) #2644
Comments
@koskimas not sure if this was more of an Objection or Knex issue, but just wanted to make you aware of this. thanks |
@heisian This is a knex issue. |
OK, sounds like a slightly deep-rooted issue.. will think this over - am using my own patched branch for the moment. Would it be prudent to warn about using |
We should probably add a warning about using |
@heisian Any chance you could create a failing test for reproduction of the issue? I want to try implementing overriding config within single query scope and would appreciate easy repro for the issue to play with. |
@heisian Actually, no need, I've succesfully reproduced everything that I needed and finalizing solution now :) |
This is great! I still have much more to learn about the Knex internals. @ekeric13 and I will check it out on Monday |
@heisian ahahaha, yeah, Knex internals are fun :D |
clutch, thanks again for fixing this @kibertoad |
@heisian Anything else before you can return upstream :-P? |
I could use some Grey Poupon.... |
:D |
@heisian 0.16.0-next4 is available now! Please let me know how testing it goes :) |
woooooo! |
@kibertoad It seems that specifying a |
ouch. thanks for bug report. let me do a hotfix and update our testsuite |
@heisian Can we do the take 2? |
@kibertoad sorry, we were on short week here last week, will be sure to test it out again today! |
@kibertoad It seems that the With |
Ah okay, I've found a big issue - module.exports = Object.assign({
client: 'pg',
connection: {
host: PSQL_HOST,
port: PSQL_PORT,
database: PSQL_DATABASE,
user: PSQL_USERNAME,
password: PSQL_PASSWORD,
},
pool: {
min: 1,
max: poolMax,
afterCreate(conn, cb) {
const queryString = 'SET timezone="UTC";'
conn.query(queryString, (err) => {
cb(err, conn)
})
},
},
migrations: {
directory: `${__dirname}/../migrations`,
stub: `${__dirname}/stubMigrations.js`,
},
seeds: {
directory: process.env.PSQL_SEED_DIR || `${__dirname}/../seeds`,
stub: `${__dirname}/stubSeeds.js`,
},
debug: ['debug'].includes(process.env.DEBUG),
},
knexSnakeCaseMappers()
}) When running migrations with exports.up = (knex) =>
knex.schema.withSchema('auth').createTable('emails', (t) => {
t.increments()
t.integer('userId').notNullable().index()
t.foreign('userId').references('id').inTable('auth.users')
t.string('email').notNullable()
t.boolean('primary')
t.boolean('verified').defaultTo(false)
t.timestamp('createdAt').notNullable()
t.timestamp('updatedAt').notNullable()
t.timestamp('deletedAt')
})
exports.down = (knex) => knex.schema.withSchema('auth').dropTable('emails') SELECT column_name FROM information_schema.columns WHERE table_name = 'emails';
/*
Returns:
id
userId
email
primary
verified
createdAt
updatedAt
deletedAt
*/ |
Ouch... that is really bad, and I just released 0.16.0... we need to fix that and release 0.16.1 asap. |
Unpublished 0.16.0 and added mention about it to changelog |
@heisian 0.16.1-next1 should have addressed CWD and query execution processing regressions, could you take a look? (and sorry for needing so many iterations to get it exactly right) |
no worries, thank you all for the efforts. I will test it out today. thanks for the update |
@heisian There is known issue that resolving knexfile without passing path to it explicitly doesn't work. If this is your use-case, please wait for next2 with fix, otherwise (hopefully) it's good enough! |
okay, we always explicitly specify the knexfile, so will give it a shot, ty for the heads up |
All of our test suites pass w/ |
@heisian It's already on npm as 0.16.1-next2 - but a final 0.16.1 is also coming in a couple of days if there are no serious regressions reported. |
oh got it ok will start using it in CI, and will report any discrepancies. I've manually verified that batches are handled correctly. thank you! |
Woohoo! Glad to hear that! |
Bug
When running
knex
migrations configured with Objection'sknexSnakeCaseWrappers
, the promise handler for the_latestBatchNumber
query always returns a default value of0
:This is because
max_batch
does not exist inobj
. The actual structure ofobj
, due toknexSnakeCaseWrappers
is:Defaulting to
0
results in a batch number of1
always being inserted into theknex_migrations
table when usingknexSnakeCaseWrappers
.In effect, this makes all of your migrations only use a single batch, which is potentially catastrophic when performing a rollback.
Environment
Knex version: 0.14.6
Database + version: Postgres 10.1
OS: macOS/Linux
Select applicable template from below.
If issue is about oracledb support tag @ atiertant. For MSSql tag @ smorey2 .
Rest of dialects doesn't need tags.
The text was updated successfully, but these errors were encountered: