Ent Versions Save

An entity framework for Go

v0.12.5

5 months ago

What's Changed

Full Changelog: https://github.com/ent/ent/compare/v0.12.0...v0.12.5

v0.11.0

1 year ago

We're very happy to announce the release of the next version of Ent: v0.11 🎊

This release contains several bug fixes, many small features, and improvements to the ent/schema, ent runtime, and ent codegen. There are 3 major features that were added to the framework: Edge Schemas, GraphQL Schema Generator and a completely new infrastructure for generating schema migrations using Atlas. Please, visit these links to learn more about these new functionalities.

In the next version, we plan to start experimenting with generics to reduce the amount of generated code and may consider exposing new generics-based extensions. Additional tasks that are on our list are query interceptors, polymorphic edges, a toolset for executing migrations safely, and a list of small runtime improvements that exist in our issue tracker.

You are welcome to join our Discord Server, Slack channel and subscribe to the Ent newsletter to get updates on the new features, proposal discussions, and content we release.

What's Changed

New Contributors

Full Changelog: https://github.com/ent/ent/compare/v0.10.1...v0.11

v0.10.1

2 years ago

Version v0.10.1 includes 2 fixes for bugs that were introduced in version v0.10.0, and additional improvements for schema migration.

What's Changed

New Contributors

Full Changelog: https://github.com/ent/ent/compare/v0.10.0...v0.10.1

v0.10.0

2 years ago

Dear community,

We're very happy to announce the release of the next version of Ent: v0.10. It has been almost six months since v0.9.1, so naturally, there's a ton of new stuff in this release. Please, read more about it in the Ent blog.

What's Changed

New Contributors

Full Changelog: https://github.com/ent/ent/compare/v0.9.1...0.10.0

v0.9.1

2 years ago

Version v0.9.1 includes 1 minor bug fix that was introduced in version v0.9.0, and additional bug fixes and improvements for the Upsert and Lock feature flags.

Bug fixes:

v0.9.0

2 years ago

We are excited to share the v0.9.0 release! 🎊

This release contains several bug fixes and many small features and improvements to the ent/schema, ent runtime, and ent-codegen. Also, 2 major features were added to the framework, Upsert/UpsertBulk APIs, and Row-level locking (see details below). See examples:

// Upsert one.
id, err := client.User.
    Create().
    SetAge(30).
    SetName("Ariel").
    OnConflict().
    SetName("Mashraki").
    ID(ctx)

// Upsert bulk.
err := client.User. 
    CreateBulk(builders...). 
    OnConflict(). 
    UpdateNewValues().
    Exec(ctx)

// Row-level locking.
tx.User.Query().
    Where(user.Name(name)).
    ForUpdate().
    Only(ctx)

In the next release, we'll introduce the new migration framework for SQL.

You are welcome to join our Slack channel and subscribe to the Ent newsletter to get updates on the new features, proposal discussions, and content we release.

Summary

ent/gen

schema/field

  • Allow simple types (and UUID types) to implement the sql.ValueScanner interface:
type DocID string
func (*DocID) Scan(value interface{}) (error) { ... }
func (DocID) Value() (driver.Value, error) { ... }
  • Make non-string ValueScanner types work with enum fields.
  • Support unique bytes.
  • Add support for setting update default functions to numeric fields:
field.Int("utime").
	UpdateDefault(func() int { ... })

schema/index

  • Add support for attaching custom annotations for indexes.

dialect/sql

  • Add union and with-recursive API for builder (see example #1599).
  • Add EXISTS (and NOT EXISTS) predicates.
  • Support for USING method in CREATE INDEX builder.
  • Add support for custom SQL query modifiers (see website).

dialct/sql/schema

  • Support for PostgreSQL and MySQL numeric and decimal types in migration.

dialect/entsql

  • Add support for CHECK annotation.
  • Support for Collation annotation in schema fields.
  • Add Prefix and PrefixColumns options for index annotations (see docs).

dialect/sql/sqlscan

  • Supporting scanning to embedded types and optional fields.

@vojta001, @chris-rock, @giautm, @rotemtam, @zeevmoney, @yonidavidson, @wenerme, @cliedeman, @DuGlaser, @davebehr1, @sywesk, @adayNU, @y-yagi, @wzyjerry, @mgabeler-lee-6rs, @tarrencev, @ivanvanderbyl, @bshihr, @MONAKA0721, @rubensayshi, @zzwx, @nmemoto, @neel229, @squarebat, @timoha, @shomodj, @masseelch, @sadmansakib, @arielitovsky, @akfaew, @amrnt, @Sacro, @alexsn - Thanks for your contribution, Ariel 🙏

v0.8.0

3 years ago

This release contains several bug fixes, performance and runtime improvements, and multiple new features in ent/schema and ent-codegen.

The next release (~1 month from now) is going to be focused on adding support for ent schema-versioning, and the initial support for the new SQL schema migration. Proposal issues/discussions are going to be posted next week.

Users are welcome to join our Slack channel and subscribe to the Ent newsletter to get ~monthly updates on the new features, proposal discussions, and content we release.

How to update

go get -u entgo.io/[email protected]

Summary

entc/gen

  • Allow extending and injecting dependencies to the generated clients/builders. See example in Ent website.
  • Add Select option to <T>UpdateOne builders. See example in Ent website:
    pedro, err := client.Pet.
       UpdateOneID(id).
       SetAge(9).
       Select(pet.FieldName, pet.FieldAge).
       Save(ctx)
    
  • (perf) Filter duplicate identifiers when loading O2M/M2O and M2M edges.
  • Allow disabling the DISTINCT clause in queries (#1371).
  • Change custom ordering/grouping functions format - This change can affect users that use custom ent.Order functions, and will require them to modify the function signature from func (*sql.Selector, func() bool) to func (*sql.Selector).
  • Code generation API - Add global annotation option - See documentation.

ent/schema

  • Major change: The codegen now uses the actual GoType defined in the schema in the generated builders/structs (see #1428). TL;DR - Using *T now means that you'll get *T as a field type (and not T). If you want to get T instead, define it in the GoType option instead, even if the sql.Scanner interface is implemented by the pointer (*T).
  • Add database cascading deletion support to edge annotations. See FK annotation.
  • Add support for custom DEFAULT clauses using entsql.Annotation:
    field.String("uuid").
       Annotation(entsql.Annotation{
           Default: "uuid_generate_v4()",
       })
    
  • Add annotation for configuring FK symbols (#1423).

dialect/sql

  • Add basic predicates for comparing 2 columns.
  • Add on-conflict handling to sql builder (initial support for upsert).

dialect/sql/schema

  • JSON column migration for MariaDB10.3.13 - Thanks @AnnatarHe for reporting this issue.
  • Initial support for Postgres arrays in migration.

contrib

  • Support additional types in entproto.
  • Support ordering by ID fields in entgql.

Thanks, @dilipkk-foyernet, @enjoylife, @rubensayshi, @bshihr, @rotemtam, @alexsn, @cliedeman, @chrisguox, @uta-mori, @Bladrak for contributing to the Ent project and participating in this release.

v0.7.0

3 years ago

This release contains 1 major feature, small improvements and bug fixes to ent codegen and its runtime, and an experimental integration with protobuf.

Global

  • Add support for edge-fields/foreign-keys in the schema (#1213) - Thanks @alexsn, @rubensayshi, @marwan-at-work, @adayNU, @aight8 and @errorhandler for the feedback and helping designing this feature properly. Please read more about it here - Thanks @rotemtam for the blog-post 🙏 .
  • Small change to all codebase. Wrap errors (replace %v with %w) when it's useful - Thanks @mgabeler-lee-6rs

Code Generation

  • The generated ent.IsConstraintError function catches now FK constraint violations (#1316) - Thanks @rotemtam
  • The edge.Annotation provides a way to override the struct-tag for the Edges field in generated models. #1315 changes the implementation to extend the struct-tag and override the default JSON tag only if it was provided by the annotation.

Schema

  • Add support for DefaultFunc in user-defined PKs (#1290)
  • Add support for MySQL spatial types in migration and add example for it - a8m/entspatial

Contrib

  • OSS entproto. An experimental package for generating .proto files from ent/schema.

CLI

  • ent init now creates a `generate.go file that matches Go 1.16 (#1300) - Thanks @uta-mori

Thanks @kercylan98, @HarikiRito, @SogoCZE, @wenj91 for reporting issues and being involved in the project.

v0.6.0

3 years ago

New import path 🎊

Package path was changed from github.com/facebook/ent to entgo.io/ent. Please use the following command (on Mac) to replace imports:

For github.com/facebookincubator/ent-contrib:

find . -type f -name '*.go' -exec sed -i '' 's/github.com\/facebookincubator\/ent-contrib/entgo.io\/contrib/g' {} +

For github.com/facebook/ent:

find . -type f -name '*.go' -exec sed -i '' 's/github.com\/facebook/entgo.io/g' {} +

schema/fields

  • Add DefaultFunc option for fields (#1153)

entc/gen

  • Add support for alternate schema/database names (Thanks @marwan-at-work). Read more here

  • Add field.Comment support in generated assets (Thanks @kerbelp)

  • Breaking change: add the edge-name as the default json tag for edge fields (#1204):

    - Users []*User
    + Users []*User `json:"users,omitempty"`
    

dialect/sql/schema

dialect/sql/sqlgraph

  • Apply predicate on update-node

Besides these, there are multiple bug fixes and small perf improvements in this release.

v0.5.4

3 years ago

Users that upgrade to this version and already use schema-hooks or the privacy policy in ent/schema, should follow the steps mentioned in https://github.com/facebook/ent/issues/1115#issuecomment-753944990.

schema/field

  • Support for indexing ID fields (Thanks @napei)
  • Allow non incremental PKs (Thanks @saantiaguilera)
  • Add DefaultFunc option to string and bytes builders
  • Remove the deprecated ValueMap option for enum builder

codegen

  • Allow field selection in query builder and eager-loading (#1077)

dialect/sql/schema

  • Add migration support for JSON columns in old versions of MariaDB (=< 10.2)
  • Support for binary columns in MySQL (Thanks @nolotz)

dialect/sql/sqlgraph

  • Small perf improvements
  • Allow arbitrary last insert id type (Thanks @cliedeman)

dialect/sql

  • Add schema options for sql builders (Thanks @marwan-at-work)