Skip to content

1.2.0

Choose a tag to compare

@Maartz Maartz released this 28 Mar 20:05
· 46 commits to main since this release

Encodable Schema Conformance

The @Schema macro now auto-generates Encodable conformance, so schema types can be passed directly to JSONEncoder without manually constructing dictionaries.

// Before — manual mapping
return try conn.json(value: donuts.map { d in
    ["id": "\(d.id)", "name": d.name, "price": "\(d.price)"]
})

// After — direct encoding
return try conn.json(encodable: donuts)

What's new

  • Auto-generated Encodable — CodingKeys enum and encode(to:) method generated at compile time for all @Schema types
  • Snake_case JSON keys — createdAt → "created_at", matching database column convention
  • @Column("custom") overrides — custom column names are used as JSON keys
  • Smart relationship encoding — @HasMany, @HasOne, @BelongsTo, @ManyToMany fields are included only when loaded; omitted entirely when .notLoaded
  • Opt-out — @Schema("secrets", encodable: false) skips Encodable generation

Fixes

  • Fixed CLI tests for Noora styled output in non-interactive environments
  • Fixed CI false positives from skipped tests being reported as failures
  • Disabled two transaction tests that trigger Swift 6 SIGBUS (runtime bug, not Spectro bug)