mashingan / anonimongo

Another Nim pure Mongo DB driver
MIT License
43 stars 5 forks source link

Doenst compile with Nim 2.2 #36

Open jmgomez opened 1 month ago

jmgomez commented 1 month ago

Nim 2.2 is about to be released and anonimongo doesnt compile with it.

samsamros commented 1 month ago

hello, please provide more details regarding the issue, including erros at compiletime, flags used to compile, and cpu architecture.

jmgomez commented 1 month ago

What fails is the Nim compilation itself. I submitted a PR with the issues I encountered so far, mostly due to changes in sigmatch. It should still be compatible with the previous version

https://github.com/mashingan/anonimongo/pull/37

cvanelteren commented 1 month ago

Any movement on this? I am looking for a database that still has support on Nim

samsamros commented 1 month ago

anonimongo still works fine for Nim 2.0, and is still supported on a community basis.

We will review the PR; however, we will likely wait until 2.2 is officially released to see if problems persist, and assess from there what changes will need to be made, if any.

In the meantime, I can confirm I have successfully been compiling and using anonimongo for the past 3-4 years. We have updated to make it compatible with 2.0 and also mongod v7. As soon as 2.2 is officially released, and volunteers are able to take a look, we will do so.

All my programs using anonimongo are compiled using Nim 2.0 and 2.0.2. Please compile using those nim versions in the meantime.

PS @jmgomez thank you for taking the time of looking into this!

cvanelteren commented 1 month ago

Good to hear! I will have a closer look at this. Nimmongo seems to be abandoned and there are sparse options in the nim ecosystems with regards to databases.

On Tue, 1 Oct 2024 at 19:15, Samuel @.***> wrote:

anonimongo still works fine for Nim 2.0, and is still supported on a community basis.

We will review the PR; however, we will likely wait until 2.2 is officially released to see if problems persist, and assess from there what changes will need to be made, if any.

In the meantime, I can confirm I have been successfully been compiling and using anonimongo for the past 3-4 years. We have updated to make it compatible with 2.0 and also mongod v7. As soon as 2.2 is officially released, and volunteers are able to take a look, we will do so.

All my programs using anonimongo are compiled using Nim 2.0 and 2.0.2. Please compile using those nim versions in the meantime.

PS @jmgomez https://github.com/jmgomez thank you for taking the time of looking into this!

— Reply to this email directly, view it on GitHub https://github.com/mashingan/anonimongo/issues/36#issuecomment-2386549659, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUVDV6ZVDMIEFYHCWTYJWDZZLKDLAVCNFSM6AAAAABOR3WP6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBWGU2DSNRVHE . You are receiving this because you commented.Message ID: @.***>

--

samsamros commented 1 month ago

confirming compiletime error in official Nim 2.2 release in Debian:

/home/localhost/.nimble/pkgs2/anonimongo-0.7.2-f277dc69661b6e0aff825708fbcc96ad7e0aa940/anonimongo/core/wire.nim(133, 20) Error: ambiguous call; both bson.newBson(table: OrderedTableRef[system.string, bson.BsonBase], stream: Streamable, filename: string) [proc declared in /home/localhost/.nimble/pkgs2/anonimongo-0.7.2-f277dc69661b6e0aff825708fbcc96ad7e0aa940/anonimongo/core/bson.nim(880, 6)] and bson.newBson(table: varargs[(string, BsonBase)]) [proc declared in /home/localhost/.nimble/pkgs2/anonimongo-0.7.2-f277dc69661b6e0aff825708fbcc96ad7e0aa940/anonimongo/core/bson.nim(1014, 6)] match for: ()

We will review @jmgomez changes in PR #37

I will begin testing changes in macros, types and bson. I will keep you posted!

samsamros commented 1 month ago

Update: So I made unambiguous calls that were in were wire.nim

line 131 I changed: newbson() -> newBson[string, BsonBase]()

proc prepareQuery*(s: var Streamable, reqId, target, opcode, flags: int32,
    collname: string, nskip, nreturn: int32,
    query = newBson[string, BsonBase](), selector = newBson[string, BsonBase](), compression = cidNoop): int {.gcsafe.} =
  ## Convert and encode the query into stream to be ready for sending
  ## onto TCP wire socket.
  var query = query
  query["$db"] = collname.split(".")[0]

  when verbose:
    dump query
...

I also updated checksums to 0.2.1 in nimble

Now, I'm still stuck with the bson macros to make a new call based on this. I have no idea how to add this with newCall in bsonify.nim:

macro bson*(p: untyped): untyped =
  ## Macro for defining BsonDocument seamless as if
  ## it's an immediate object syntax supported by Nim.
  result = newcall("newBson")
  for el in p:
    let ident = $el[0]
    let val = el[1]
    bsonifyCheckBody(val)
    result.add quote do:
      (`ident`, `objval`)

Caution: I cannot test this without first going over all compile time errors, I'm not sure this will work, until I update the macros Maybe we will transform this to AST? Give me a bit more time to figure it out.