tanweerdev / fat_ecto Goto Github PK
View Code? Open in Web Editor NEWQuery mechanism for Ecto
Home Page: https://hexdocs.pm/fat_ecto
Query mechanism for Ecto
Home Page: https://hexdocs.pm/fat_ecto
Hi! First, let me thank you for all the effort in this library ๐
I'm opening this issue because there's seems to be an error when applying eq
operations with DateTime
values (potentially with other date-time structs too).
The one bellow works correctly:
opts = %{
"child_table" => %{
"$where" => %{
"inserted_at" => %{
"$gt" => ~U[2020-01-01 00:00:00Z],
"$lt" => ~U[2022-01-01 00:00:00Z]
},
"value" => 3000
}
}
}
build!(MyApp.Model, %{"include" => opts})
But the following example doesn't seem to work ๐. Is there's something wrong with the options and trying to apply in this case?
opts = %{
"child_table" => %{
"$where" => %{
"inserted_at" => ~U[2022-01-01 00:00:00Z],
"value" => 3000
}
}
}
build!(MyApp.Model, %{"include" => opts})
Here's the stack trace of the error:
[error] ** (Protocol.UndefinedError) protocol Enumerable not implemented for ~U[2020-01-01 00:00:00Z] of type DateTime (a struct)
(elixir 1.11.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.11.2) lib/enum.ex:141: Enumerable.reduce/3
(elixir 1.11.2) lib/enum.ex:3461: Enum.reduce/3
(stdlib 3.14) maps.erl:233: :maps.fold_1/3
(fat_ecto 0.5.0) lib/fat_ecto/query/where.ex:741: FatEcto.FatQuery.FatWhere.build_where/4
(fat_ecto 0.5.0) lib/fat_ecto/query/include.ex:113: anonymous fn/4 in FatEcto.FatQuery.FatInclude.build_include/4
(stdlib 3.14) maps.erl:233: :maps.fold_1/3
Upon compiling fat_ecto
for the first time, I get the following warnings:
==> fat_ecto
Compiling 25 files (.ex)
warning: function nil.all/1 is undefined (module nil is not available)
Found at 2 locations:
lib/fat_ecto/context.ex:68
lib/fat_ecto/paginator.ex:66
warning: function nil.all/2 is undefined (module nil is not available)
lib/fat_ecto/context.ex:140
warning: function nil.delete/1 is undefined (module nil is not available)
lib/fat_ecto/context.ex:116
warning: function nil.delete_all/1 is undefined (module nil is not available)
lib/fat_ecto/context.ex:122
warning: function nil.get/2 is undefined (module nil is not available)
Found at 2 locations:
lib/fat_ecto/context.ex:76
lib/fat_ecto/context.ex:85
warning: function nil.get!/2 is undefined (module nil is not available)
lib/fat_ecto/context.ex:72
warning: function nil.get_by/2 is undefined (module nil is not available)
lib/fat_ecto/context.ex:96
warning: function nil.insert/1 is undefined (module nil is not available)
lib/fat_ecto/context.ex:104
warning: function nil.one/1 is undefined (module nil is not available)
Found at 6 locations:
lib/fat_ecto/context.ex:24
lib/fat_ecto/context.ex:43
lib/fat_ecto/context.ex:49
lib/fat_ecto/context.ex:56
lib/fat_ecto/paginator.ex:76
lib/fat_ecto/query.ex:158
warning: function nil.preload/2 is undefined (module nil is not available)
Found at 5 locations:
lib/fat_ecto/context.ex:68
lib/fat_ecto/context.ex:78
lib/fat_ecto/context.ex:86
lib/fat_ecto/context.ex:97
lib/fat_ecto/context.ex:141
warning: function nil.update/1 is undefined (module nil is not available)
lib/fat_ecto/context.ex:111
I see that one can use this module by use FatEcto.FatContext, repo: MyRepo
, but I'm not doing this as I don't need this module so it generates a lot of useless warnings. Any ideas?
Hi again ๐
I was wondering how could we create the following query?
select parent.*
left join child on child.parent_id = parent.id
where ((child.field > 5 and child.field < 2) or (child.field IS NULL))
I know that there's the "$or"
key at the moment but it doesn't seem to do what we need ๐ข.
Thanks in advance again for the help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.