Giter VIP home page Giter VIP logo

calecto's People

Contributors

duijf avatar fabi755 avatar hojgr avatar lau avatar lowks avatar princemaple avatar riacataquian avatar ryankask avatar stevedomin avatar sumerman avatar tomosjohnrees avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

calecto's Issues

Integration tests

Ecto has integration tests (see https://github.com/elixir-lang/ecto#running-tests ). It would be cool if we had something like that, so when running e.g. MIX_ENV=pg mix test, a database would be created and we would test the schema, queries etc. That way the integration with both Ecto and the database would be tested.

Duplicated modules

Hi, I got the following problem when I try to build a release with calecto:

When you include both Ecto and Calecto in your applications list and try to build a release (in my case with distillery) then you get a "Duplicated modules" error because your types have the same names as Ecto's types:

    Duplicated modules:
    'Elixir.Ecto.DataType.Time' specified in ecto and calecto
    'Elixir.Ecto.DataType.NaiveDateTime' specified in ecto and calecto
    'Elixir.Ecto.DataType.DateTime' specified in ecto and calecto
    'Elixir.Ecto.DataType.Date' specified in ecto and calecto

How do you deal with this?

Rename Calecto.Model

Now that Ecto.Model is no longer used, while Calecto.Model still works, it should probably be renamed.
Calecto.Schema ?

Loading / Encoding issues.

Hey @lau, I'm trying to use the Calecto.DateTime type and getting the following error when writing a value:

** (ArgumentError) could not encode date/time: {{{2018, 8, 9}, {12, 56, 42, 0}}, -14400, "EST5EDT"}

This error happens when you are by-passing Ecto's Query API by
using either Ecto.Adapters.SQL.query/4 or Ecto fragments. This
makes Ecto unable to properly cast the type. You can fix this by
explicitly telling Ecto which type to use via `type/2` or by
implementing the Ecto.DataType protocol for the given value.

    (ecto) lib/ecto/adapters/postgres/datetime.ex:88: Ecto.Adapters.Postgres.Timestamp.encode!/1
    (sensetra) lib/ecto/adapters/postgres/datetime.ex:126: Sensetra.PostgresTypes.encode_params/3
    (postgrex) lib/postgrex/query.ex:45: DBConnection.Query.Postgrex.Query.encode/3
    (db_connection) lib/db_connection.ex:1079: DBConnection.describe_run/5
    (db_connection) lib/db_connection.ex:1150: anonymous fn/4 in DBConnection.run_meter/5
    (db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
    (ecto) lib/ecto/adapters/postgres/connection.ex:86: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6

A similar error happens if I try to load a value

Versions:

Elixir 1.7.2
Ecto 2.2.10
Calecto 0.17.0

Kalecto.Model macro usage

Hi,

First off, thanks very much for your work on these datetime packages. Super, super useful.

I'm still relatively new to Elixir but I am confused by the instructions in the README:

In your Ecto models, where you have a schema definition with a timestamps line, add use Kalecto.Model at the top of the module, below the line that says use Ecto.Model

When using both use lines in an Ecto model definition, compilation seems to raise this warning:

model.ex:1: warning: this clause cannot match because a previous clause at line 1 always matches

...and looking at the macro code itself, it seems to declare use Ecto.Model for you.

So I guess the question is, am I missing a reason for asking users to specify both lines?

cheers,
Darian

0.4.0 breaks my build

"Because of protocols, they can still be used with the Calendar functions for formatting, timezone shifting etc." this line from the changelog is simply not true. Functions like Calendar.DateTime.diff are actually defined on data structures from Calendar.

Furthermore I actually have some of my protocols implemented for Calendar, now I have to duplicate this code for Calecto structures.

And just out of curiosity why you decided to change the underlaying data structures?

Ecto 3.x.y dependency question

Hi!
Does Calecto work with Ecto 3.x.y? I want to use custom Calecto.DateTime Ecto type for a project.
If that's the case we could update the ecto dependency

Calendar.DateTime can't be used directly in queries

The following code fails because you can't use DateTime struct directly in queries:

 def all_users() do
    now = Calendar.DateTime.now_utc |> Calecto.DateTimeUTC.cast
    from(u in Eager.User,
      where: fragment("(?).wall_time > ?", u.start_datetime, ^now),
      select: u)
  end
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in Ecto.Adapters.Postgres.DateTime.encode_timestamp/1
        (ecto) lib/ecto/adapters/postgres/datetime.ex:47: Ecto.Adapters.Postgres.DateTime.encode_timestamp(%Calendar.DateTime{abbr: "UTC", day: 3, hour: 23, min: 53, month: 2, sec: 58, std_off: 0, timezone: "Etc/UTC", usec: 687669, utc_off: 0, year: 2016})
        (postgrex) lib/postgrex/query.ex:90: DBConnection.Query.Postgrex.Query.do_encode/3
        (postgrex) lib/postgrex/query.ex:51: DBConnection.Query.Postgrex.Query.encode/3
        (db_connection) lib/db_connection.ex:885: DBConnection.describe_execute/5
        (db_connection) lib/db_connection.ex:1009: DBConnection.run_begin/3
        (db_connection) lib/db_connection.ex:957: DBConnection.run_meter/3
        (db_connection) lib/db_connection.ex:421: DBConnection.query/4
        (postgrex) lib/postgrex.ex:105: Postgrex.query/4
        (ecto) lib/ecto/adapters/postgres/connection.ex:31: Ecto.Adapters.Postgres.Connection.query/4
        (stdlib) timer.erl:197: :timer.tc/3
        (ecto) lib/ecto/adapters/sql.ex:262: Ecto.Adapters.SQL.query/7
        (ecto) lib/ecto/pool.ex:159: Ecto.Pool.do_run/4
        (ecto) lib/ecto/adapters/sql.ex:247: Ecto.Adapters.SQL.query/6
        (ecto) lib/ecto/adapters/sql.ex:225: Ecto.Adapters.SQL.query/5
        (ecto) lib/ecto/adapters/sql.ex:183: Ecto.Adapters.SQL.query!/5
        (ecto) lib/ecto/adapters/sql.ex:481: Ecto.Adapters.SQL.execute/6
        (ecto) lib/ecto/repo/queryable.ex:95: Ecto.Repo.Queryable.execute/5
        (ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4

Update the hex package

Hi, it'd be great if you update the hex package. I'm getting elixir warnings. They're fixed in master, but these fixes are not uploaded to hex.pm
screen shot 2016-10-14 at 12 33 08

Ecto cannot cast DateTime in query

Getting this error when using a Calendar.DateTime in a where:

Repo.all(from t in Tactic, where: t.account_id == ^account_id and t.updated_at >= ^sinceb, select: t)
** (UndefinedFunctionError) undefined function: Calendar.DateTime.type/0
(ecto) lib/ecto/query/planner.ex:124: Ecto.Query.Planner.prepare/3
(ecto) lib/ecto/query/planner.ex:66: Ecto.Query.Planner.query/4
(ecto) lib/ecto/repo/queryable.ex:91: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4

how to query

Hi,

Great package, thanks a lot.

I have a question regarding making queries around datetime related schema

lets say we have this code

from r in Record,
where: r.start >= ^start and r.finish <= ^finish

what is the type that start and finish are supposed to be of? do they have to be the Calecto type that matches the field?

Is dump/1 called on start/finish? If so, what do you think about adding another dump/1 that is equivalent to this cast?

so we can write something like below and pass in raw datetime strings

 def index(conn, %{
   "user_id" => user_id,
   "started_at" => started_at,
   "finished_at" => finished_at
 }) do
   records = Repo.all(
     from r in Record,
     where: r.user_id == ^user_id
-       and r.started_at >= ^cast!(started_at)
+       and r.started_at >= ^started_at
-       and r.finished_at <= ^cast!(finished_at)
+       and r.finished_at <= ^finished_at
   )
   render(conn, "index.json", records: records)
 end

ecto3 branch: Calecto.DateTime does not conform to Ecto 3.5 Ecto.Type behavior

Upgrading Ecto to 3.5 results in the following error when using the Calecto.DateTime type on the ecto3 branch...

** (UndefinedFunctionError) function Calecto.DateTime.equal?/2 is undefined or private, but the behaviour Ecto.Type expects it to be present

I've been using Calecto.DateTime for the past year without issue, but related tests fail upon upgrading to 3.5.

Unlock calendar

Hi @lau
Could you give this project a bump so it allows calendar 0.17? Maybe remove the .0 in ~> 0.16.0 :)

Thanks

Converting non-UTC timezones to UTC during cast

I am a little confused on how to manage dates my phoenix app when my DB is on UTC and most (but not all) my users edit dates in a specific timezone (that is not UTC).

I posted my question to Elixir Forum (https://elixirforum.com/t/confused-with-storing-dates-with-calendar-ecto/2162) and José suggested create a PR for Calecto.DateTimeUTC.cast to accept a non "etc/utc" timezone and convert it to utc.

What are your thoughts on this?

Thanks in advance.

Quick licensing question

Hi, what is the license for Calecto? I'm setting license information in ports and this one is missing :)

Compile warnings

Compiling calecto produces the following warnings: (Ecto 2.0 & Elixir 1.3)

warning: function Ecto.Type.blank?/1 is undefined or private
  lib/calecto/date.ex:18
warning: function Ecto.Type.blank?/1 is undefined or private
  lib/calecto/date_time.ex:21
warning: function Ecto.Type.blank?/1 is undefined or private
  lib/calecto/date_time_utc.ex:19
warning: function Ecto.Type.blank?/1 is undefined or private
  lib/calecto/naive_date_time.ex:19
warning: function Ecto.Type.blank?/1 is undefined or private
  lib/calecto/time.ex:19

It looks like Ecto.Type.blank?/1 was removed in Ecto 0.9. I don't know which versions of Ecto you want to support, but if you're open to removing this, I'll send a PR.

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.