datanoise / mongo.cr

Crystal binding for MongoDB C Driver
MIT License
97 stars 35 forks source link

update to work with Crystal 0.24.1 #35

Closed sam0x17 closed 6 years ago

sam0x17 commented 6 years ago

There are a few minor syntax changes that prevent mongo.cr from compiling with the new version of Crystal. I fixed a few of them manually, however the last one is a legit bug that I have not been able to figure out, involving how the port number is parsed in certain circumstances. The spec failure I was unable to fix is this one:

crystal spec spec/uri_spec.cr:21 # Mongo::Uri should be able to create new uri with host and port

I'll post a PR if I do get it working

sam0x17 commented 6 years ago

update: here is my fork, where I am attempting to try some things to fix this

https://github.com/sam0x17/mongo.cr

sam0x17 commented 6 years ago

Note that I have been unable to fix that last bug -- any help would be greatly appreciated

sam0x17 commented 6 years ago

@datanoise any headway on this?

watzon commented 6 years ago

I fixed the last broken spec on your fork @sam0x17, as soon as my PR gets merged you should be able to PR here

sam0x17 commented 6 years ago

Looks like I'm still getting the same errors with those changes. Are you sure you are using Crystal 0.24.1?

Failures:

  1) Mongo::Uri should be able to create new uri
     Failure/Error: host.port.should eq(27017)

       Expected: 27017
            got: 0_u16

     # spec/uri_spec.cr:10

  2) Mongo::Uri should work with various ports
     Failure/Error: host.port.should eq(1443)

       Expected: 1443
            got: 0_u16

     # spec/uri_spec.cr:18

  3) Mongo::Uri should be able to create new uri with host and port
     Failure/Error: host.port.should eq(27017)

       Expected: 27017
            got: 0_u16

     # spec/uri_spec.cr:26

Finished in 879.77 milliseconds
75 examples, 3 failures, 0 errors, 0 pending

Failed examples:

crystal spec spec/uri_spec.cr:5 # Mongo::Uri should be able to create new uri
crystal spec spec/uri_spec.cr:13 # Mongo::Uri should work with various ports
crystal spec spec/uri_spec.cr:21 # Mongo::Uri should be able to create new uri with host and port

Out of curiosity what version of mongodb are you using @watzon? Looks like I have:

$ mongod --version
db version v3.4.10
git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64
watzon commented 6 years ago

Here's Crystal

➜ crystal -v
Crystal 0.24.1 (2017-12-20)

LLVM: 5.0.0
Default target: x86_64-unknown-linux-gnu

and mongo

➜ mongod --version
db version v3.6.2
git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

Looks like my mongo version is newer, but all the specs are passing for me.

sam0x17 commented 6 years ago

I will try with newer mongo and if that works I will merge