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

Breaking changes information missing from ChangeLog #2414

Open
nickb937 opened this issue Nov 11, 2024 · 1 comment
Open

Breaking changes information missing from ChangeLog #2414

nickb937 opened this issue Nov 11, 2024 · 1 comment

Comments

@nickb937
Copy link
Contributor

nickb937 commented Nov 11, 2024

Upgrading from SeaORM 0.12 to 1.1

There seem to be some changes that are breaking changes but aren't mentioned in the Changelog, which tripped me up during an upgrade. It would be helpful to expand the information in the ChangeLog for others.

  1. The requirement to always define an ActiveModel for a table. In v0.12 I did not implement ActiveModel for some tables because they are read-only, managed directly by some database triggers. In this instance SeaORM defines the schema and I wanted a compile error should somebody try to write code to update the rows.
error[E0412]: cannot find type `ActiveModel` in this scope
 --> table.rs:5:39
  |
5 | #[derive(Copy, Clone, Default, Debug, DeriveEntity)]
  |                                       ^^^^^^^^^^^^
  |
  = note: this error originates in the derive macro `DeriveEntity` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items

I see it's now written in the doc here that it should always be defined: https://www.sea-ql.org/SeaORM/docs/generate-entity/entity-structure/

  1. ColumnType::String definitions seem to have changed, wrapped by StringLen.
    ColumnType::String(Some(32)).def()

  2. use sea_orm::sea_query::BlobSize has been Dropped, but no indication of what it should have been replaced with.

I guess that ColumnType::Binary(BlobSize::Blob(None)).def() should be ColumnType::Binary(0).def()

ColumnType defines:

    Binary(u32),
    VarBinary(StringLen),

On PostgreSQL should I now be using ColumnType::VarBinary(StringLen::None) or ColumnType::Binary(0).def() or does it matter?

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 12, 2024

Yes, I think I changed the derive macro in #2186 I know that is breaking, and it should only impact relatively few users. we've never thought about the "entity without active model = read only" use case. and may be we can work something out to make it a feature.

I am not sure if it will work, can a trait associated constant, say READ_ONLY = true in EntityTrait, trigger a compile-time error with a const fn shall we attempt to call save?

regarding binary, BlobSize is really a MySQL thing, it doesn't exist in Postgres, usually VarBinary is used.

ref. https://docs.rs/sea-query/latest/sea_query/table/enum.ColumnType.html it's bytea all along

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

2 participants