bun-query-builder 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -24660,7 +24660,8 @@ class ModelInstance {
24660
24660
  const attrs = this._definition.attributes;
24661
24661
  for (const [key, value] of Object.entries(data)) {
24662
24662
  const attr = findAttributeDef(attrs, key);
24663
- if (attr?.fillable && !attr?.guarded) {
24663
+ const isImplicitForeignKey = !attr && toSnakeCase(key).endsWith("_id");
24664
+ if (attr?.fillable && !attr?.guarded || isImplicitForeignKey) {
24664
24665
  if (this._original === null)
24665
24666
  this._original = { ...this._attributes };
24666
24667
  this._attributes[toSnakeCase(key)] = value;
@@ -24710,6 +24711,11 @@ class ModelInstance {
24710
24711
  data[col] = this._attributes[col];
24711
24712
  }
24712
24713
  }
24714
+ for (const key of Object.keys(this._attributes)) {
24715
+ if (key.endsWith("_id") && key !== pk && !(key in data)) {
24716
+ data[key] = this._attributes[key];
24717
+ }
24718
+ }
24713
24719
  if (timestampsEnabled(this._definition)) {
24714
24720
  const now = formatNow();
24715
24721
  data.created_at = now;
@@ -30768,7 +30774,7 @@ function getPrefix() {
30768
30774
  }
30769
30775
  var prefix = getPrefix();
30770
30776
  // package.json
30771
- var version2 = "0.1.40";
30777
+ var version2 = "0.1.41";
30772
30778
 
30773
30779
  // bin/cli.ts
30774
30780
  init_actions();
package/dist/src/index.js CHANGED
@@ -24660,7 +24660,8 @@ class ModelInstance {
24660
24660
  const attrs = this._definition.attributes;
24661
24661
  for (const [key, value] of Object.entries(data)) {
24662
24662
  const attr = findAttributeDef(attrs, key);
24663
- if (attr?.fillable && !attr?.guarded) {
24663
+ const isImplicitForeignKey = !attr && toSnakeCase(key).endsWith("_id");
24664
+ if (attr?.fillable && !attr?.guarded || isImplicitForeignKey) {
24664
24665
  if (this._original === null)
24665
24666
  this._original = { ...this._attributes };
24666
24667
  this._attributes[toSnakeCase(key)] = value;
@@ -24710,6 +24711,11 @@ class ModelInstance {
24710
24711
  data[col] = this._attributes[col];
24711
24712
  }
24712
24713
  }
24714
+ for (const key of Object.keys(this._attributes)) {
24715
+ if (key.endsWith("_id") && key !== pk && !(key in data)) {
24716
+ data[key] = this._attributes[key];
24717
+ }
24718
+ }
24713
24719
  if (timestampsEnabled(this._definition)) {
24714
24720
  const now = formatNow();
24715
24721
  data.created_at = now;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.1.40",
4
+ "version": "0.1.41",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",