question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow null on a field with a relationship does not work

See original GitHub issue

The resulting table ends up with a not null constraint, even when creating the field manually instead of using the Relationship helper functions:

parentId: {
	type: DataTypes.INTEGER,
	allowNull: true,
	relationship: {
		kind: "single",
		model: Location,
	}
}

I also tried setting parentId: null in the static defaults object but the result is the same, the table ends up being created with a not null constraint.

I’m reading the code to see if I can find why this is happening.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
stillalivxcommented, Nov 7, 2020

Alright! I did the changes. You can use my fork to import DenoDB while we wait the merge:

import { Database, Models, Relationships } from "https://raw.githubusercontent.com/stillalivx/denodb/master/mod.ts" 

If you have a problem, let me know. If you don’t, please close the issue.

Good coding! 🙂

0reactions
sntg-pcommented, Nov 7, 2020

No problem! Actually yes, I was having problems with the automatically created timestamp fields but I just decided to stop using that option and it worked so I stopped trying to mess with it.

I just checked your repo and I remember finding your pull request when searching about that problem I was having, I was hoping your pull request got merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Handling null in one-to-many relationship
Hello. I have 2 simple tables with what I would expect to be a 1 to many relationship. Problem 1. PowerBI however imposes...
Read more >
sql - What does/should NULL mean along with FK relationships
It's perfectly acceptable, and it means that, if that column has any value, its value must exist in another table.
Read more >
How To Enter Empty (Null) Into Table Field With Relationship ...
Basically I want to give the user the chance to enter nothing, i.e. NULL, i.e. not pick anything from the dropdown list.
Read more >
Why shouldn't we allow NULLs? - DBA Stack Exchange
NULL values represent unknown data NOT unused data. If you have an employee table that has a termination date field. A null value...
Read more >
Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found