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

One relation isNullable property should be !notNull rather than notNull #2365

Open
danielsharvey opened this issue May 23, 2024 · 0 comments

Comments

@danielsharvey
Copy link

The One relation appears to have inverted logic for the isNullable property.

(config?.fields.reduce<boolean>((res, f) => res && f.notNull, true)
?? false) as Equal<TColumns[number]['_']['notNull'], true>,

Specifically, it appears to set isNullable to true if all parts of the relation's fields are notNull() columns.

It looks to me like the isNullable should be set to true if none of the relation's fields are notNull().

The above logic is from the createOne() method:

export function createOne<TTableName extends string>(sourceTable: Table) {
return function one<
TForeignTable extends Table,
TColumns extends [
AnyColumn<{ tableName: TTableName }>,
...AnyColumn<{ tableName: TTableName }>[],
],
>(
table: TForeignTable,
config?: RelationConfig<TTableName, TForeignTable['_']['name'], TColumns>,
): One<
TForeignTable['_']['name'],
Equal<TColumns[number]['_']['notNull'], true>
> {
return new One(
sourceTable,
table,
config,
(config?.fields.reduce<boolean>((res, f) => res && f.notNull, true)
?? false) as Equal<TColumns[number]['_']['notNull'], true>,
);
};
}

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

1 participant