Giter Club home page Giter Club logo

Comments (8)

jwoertink avatar jwoertink commented on September 13, 2024 1

I consider, add shards.override.yml same as change shards.yml directly, right?

No, these are not the same. https://crystal-lang.org/reference/1.12/man/shards/index.html#fixing-dependency-version-conflicts

Using the shard override file is the proper way to handle this. Even Avram uses it https://github.com/luckyframework/avram/blob/main/shard.override.yml 😄

from avram.

jwoertink avatar jwoertink commented on September 13, 2024

This doesn't look like a bug. You created your column in the migration as Float

add number : Float64, precision: 10, scale: 5

Then in your model, you said it was Float | Nil

column number : Float64?

All Float columns are stored as PG::Numeric in the database, so it's trying to convert your PG::Numeric to Float | Nil as your model has, but the type should be Float.

from avram.

zw963 avatar zw963 commented on September 13, 2024

Hi, same issue when change the column type to Float64?

require "pg"
require "avram"

class AppDatabase < Avram::Database
end

AppDatabase.configure do |settings|
  settings.credentials = Avram::Credentials.new(database: "test_db", username: "postgres", hostname: "localhost")
end

Avram.configure do |settings|
  settings.database_to_migrate = AppDatabase
  settings.lazy_load_enabled = true
end

class CreateFoo::V20240420041991 < Avram::Migrator::Migration::V1
  def migrate
    create table_for(Foo), if_not_exists: true do
      primary_key id : Int64
      add number : Float64?, precision: 10, scale: 5
      add_timestamps
    end
  end

  def rollback
    drop table_for(Foo)
  end
end

Avram::Migrator::Runner.drop_db(true)
Avram::Migrator::Runner.create_db(true)
Avram::Migrator::Runner.new.run_next_migration

abstract class BaseModel < Avram::Model
  def self.database : Avram::Database.class
    AppDatabase
  end
end

class Foo < BaseModel
  table do
    column number : Float64?
  end
end

Foo::SaveOperation.create!(number: 70884.70074)
Foo::SaveOperation.create!(number: 50530.49889)
Foo::SaveOperation.create!(number: 37639.3706)
Foo::SaveOperation.create!(number: 18688.18317)
Foo::SaveOperation.create!(number: 18688.18317)
Foo::SaveOperation.create!

query = Foo::BaseQuery.new

query.number.select_min

from avram.

zw963 avatar zw963 commented on September 13, 2024

Hi, how to the newest changes on main branch in a exists lucky project?

Following is my shards.yml

---
name: college
version: 0.1.0
targets:
  college:
    main: src/college.cr
crystal: '>= 1.12.1'
dependencies:
  lucky:
    github: luckyframework/lucky
    version: ~> 1.2.0
  avram:
    github: luckyframework/avram
    version: ~> 1.2.0
  carbon:
    github: luckyframework/carbon
    version: ~> 0.5.1
  carbon_sendgrid_adapter:
    github: luckyframework/carbon_sendgrid_adapter
    version: ~> 0.5.0
  lucky_env:
    github: luckyframework/lucky_env
    version: ~> 0.2.0
  lucky_task:
    github: luckyframework/lucky_task
    version: ~> 0.3.0
  authentic:
    github: luckyframework/authentic
    version: '>= 1.0.0, < 2.0.0'
  jwt:
    github: crystal-community/jwt
    version: ~> 1.6.0
  baked_file_system_mounter:
    github: crystal-china/baked_file_system_mounter
development_dependencies:
  lucky_flow:
    github: luckyframework/lucky_flow
    version: ~> 0.10.0

I get error like this when i run shards update.

 ╰─ $ shards update
Resolving dependencies
Fetching https://github.com/luckyframework/lucky.git
Fetching https://github.com/luckyframework/avram.git
Fetching https://github.com/luckyframework/carbon_sendgrid_adapter.git
Fetching https://github.com/luckyframework/carbon.git
Fetching https://github.com/luckyframework/lucky_env.git
Fetching https://github.com/luckyframework/lucky_task.git
Fetching https://github.com/luckyframework/authentic.git
Fetching https://github.com/crystal-community/jwt.git
Fetching https://github.com/crystal-china/baked_file_system_mounter.git
Fetching https://github.com/luckyframework/lucky_flow.git
Unable to satisfy the following requirements:

- `avram (branch main)` required by `shard.yml`
- `avram (>= 1.0.0)` required by `authentic 1.0.0`
Failed to resolve dependencies

from avram.

jwoertink avatar jwoertink commented on September 13, 2024

@zw963 You need to create a new shards.override.yml file with

dependencies:
  avram:
    github: luckyframework/avram
    branch: main

from avram.

zw963 avatar zw963 commented on September 13, 2024

@zw963 You need to create a new shards.override.yml file with

dependencies:
  avram:
    github: luckyframework/avram
    branch: main

Sorry, i paste the wrong file, following is my shards.yml, it not work.

---
name: college
version: 0.1.0
targets:
  college:
    main: src/college.cr
crystal: '>= 1.12.1'
dependencies:
  lucky:
    github: luckyframework/lucky
    version: ~> 1.2.0
  avram:
    github: luckyframework/avram
    branch: main
  carbon:
    github: luckyframework/carbon
    version: ~> 0.5.1
  carbon_sendgrid_adapter:
    github: luckyframework/carbon_sendgrid_adapter
    version: ~> 0.5.0
  lucky_env:
    github: luckyframework/lucky_env
    version: ~> 0.2.0
  lucky_task:
    github: luckyframework/lucky_task
    version: ~> 0.3.0
  authentic:
    github: luckyframework/authentic
    version: '>= 1.0.0, < 2.0.0'
  jwt:
    github: crystal-community/jwt
    version: ~> 1.6.1
  baked_file_system_mounter:
    github: crystal-china/baked_file_system_mounter
development_dependencies:
  lucky_flow:
    github: luckyframework/lucky_flow
    version: ~> 0.10.0

the diff is:

diff --git a/shard.yml b/shard.yml
index 7735200..208b9bf 100644
--- a/shard.yml
+++ b/shard.yml
@@ -11,7 +11,7 @@ dependencies:
     version: ~> 1.2.0
   avram:
     github: luckyframework/avram
-    version: ~> 1.2.0
+    branch: main
   carbon:
     github: luckyframework/carbon
     version: ~> 0.5.1
@@ -29,7 +29,7 @@ dependencies:
     version: '>= 1.0.0, < 2.0.0'
   jwt:
     github: crystal-community/jwt
-    version: ~> 1.6.0
+    version: ~> 1.6.1
   baked_file_system_mounter:
     github: crystal-china/baked_file_system_mounter
 development_dependencies:

Get same error as above.

I consider, add shards.override.yml same as change shards.yml directly, right?

from avram.

zw963 avatar zw963 commented on September 13, 2024

If remove authentic shards, update to use main branch of avram work.

diff --git a/shard.lock b/shard.lock
index 4065909..961005a 100644
--- a/shard.lock
+++ b/shard.lock
@@ -1,12 +1,8 @@
 version: 2.0
 shards:
-  authentic:
-    git: https://github.com/luckyframework/authentic.git
-    version: 1.0.0
-
   avram:
     git: https://github.com/luckyframework/avram.git
-    version: 1.2.0
+    version: 1.2.0+git.commit.1326a8ea7583b91169993194802bb0875172a9c3
 
   backtracer:
     git: https://github.com/sija/backtracer.cr.git

from avram.

zw963 avatar zw963 commented on September 13, 2024

Confirm the main branch fix my issue.

Thanks.

BTW: above override file name typo, it should be shard.override.yml

from avram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.