Skip to content
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

Optional columns when inserting #6

Closed
gilbert opened this issue Apr 23, 2019 · 6 comments
Closed

Optional columns when inserting #6

gilbert opened this issue Apr 23, 2019 · 6 comments

Comments

@gilbert
Copy link
Contributor

gilbert commented Apr 23, 2019

I noticed nullable columns are still required to specify when inserting. For example:

export class Test {
  id = new UuidColumn().primaryKey().notNull();
  name = new TextColumn();
  createdAt = new TimestampWithTimeZoneColumn().notNull().default(new Now());
}
// ...
db.insertInto(db.test).values({
  name: null,
  createdAt: null,
})

here name: null is required even though it's nullable and createdAt: null is required even though it has a default.

Is this a limitation that you ran into? Or just haven't gotten around to making them optional in JS-land too? I can write a PR if it's possible.

@martijndeh
Copy link
Contributor

Nowadays it’s possible to omit some types, that’s how the id property is excluded. But it’s hardcoded now so not really elegant.

It might be possible today to omit nullable and not null with defaults but I haven’t investigated further. I agree it would be nice if those nullable or default values may be omitted! So if you have time would be nice to understand if and how we can fix this! :)

@gilbert
Copy link
Contributor Author

gilbert commented Apr 24, 2019

I have some questions about the code base. What's a good way to contact you? Perhaps https://gitter.im?

@martijndeh
Copy link
Contributor

I’m working on something which solves this.

@martijndeh
Copy link
Contributor

The changes are available in mammoth@next. Still needs some work to get the new set up in shape.

@gilbert
Copy link
Contributor Author

gilbert commented Jan 21, 2020

Looks great so far! Super exciting.

@martijndeh
Copy link
Contributor

Tests are passing again. I'll close this now as I consider this resolved. I'll try to get a release ready in the next few days. There is still some work left on the cli and the generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants