Giter Site home page Giter Site logo

Support MS SQL Server about pop HOT 23 OPEN

gobuffalo avatar gobuffalo commented on July 17, 2024
Support MS SQL Server

from pop.

Comments (23)

marpio avatar marpio commented on July 17, 2024 1

Waiting for jmoiron/sqlx#406

from pop.

marpio avatar marpio commented on July 17, 2024 1

Awesome @stanislas-m I will need some time to make it work since a lot changed in buffalo/pop since March.

from pop.

markbates avatar markbates commented on July 17, 2024

Completely agree, it just needs someone to step up and implement it. :)

from pop.

marpio avatar marpio commented on July 17, 2024

Well, I'm interested. Although I probably would need some guidance.

from pop.

markbates avatar markbates commented on July 17, 2024

Of course! I’m happy to offer guidance. @mclark4386 implemented cockroach support recently. I’m sure he’ll be happy to offer some guidance along the way too!

from pop.

marpio avatar marpio commented on July 17, 2024

@markbates So I took a glance at the cockroach commits and if I understand correctly the main task would be to implement sqlserver.go and fizz/translators/sqlserver.go similar to mysql/postgres/cockroach. Is that right?

from pop.

markbates avatar markbates commented on July 17, 2024

That’s the basics of it, yep. I would pick the implementation that’s closest to MS, I’ve never used it, and use that as a starting point. Rename a few things, point them at the MS DB and see what the tests yell at you about.

from pop.

marpio avatar marpio commented on July 17, 2024

@markbates hmm... travis doesn't support ms sql server. would you consider to add appveyor integration?
https://www.appveyor.com/

from pop.

markbates avatar markbates commented on July 17, 2024

from pop.

marpio avatar marpio commented on July 17, 2024

@markbates true - i've found this: https://github.com/aspnet/EntityFrameworkCore/pull/7842/files
I'll go with travis then.

from pop.

mclark4386 avatar mclark4386 commented on July 17, 2024

@marpio happy to help if you have questions! Sounds like you have a good start going.

from pop.

marpio avatar marpio commented on July 17, 2024

@markbates short question - what is the purpose of the {db}_meta.go files in the fiz/translators package? Why doesn't postgres need it?

from pop.

markbates avatar markbates commented on July 17, 2024

Some of the translators, like SQLite (for example), need additional meta information about the table(s), indexes, etc… to create the proper sql for things such as renaming a column.

Postgres is a nice db and things just work. :)

from pop.

marpio avatar marpio commented on July 17, 2024

@markbates thanks

from pop.

marpio avatar marpio commented on July 17, 2024

I'm having some difficulties - sqlx doesn't support the sqlserver parameter syntax so:

// this doesn't work
tx.MustExec("INSERT INTO person (first_name, last_name, email) VALUES ($1, $2, $3)", "Jason", "Moiron", "[email protected]")
// this works
tx.MustExec("INSERT INTO person (first_name, last_name, email) VALUES (@p1, @p2, @p3)", "Jason", "Moiron", "[email protected]")

// but this doesn't
tx.NamedExec("INSERT INTO person (first_name, last_name, email) VALUES (:first_name, :last_name, :email)", &Person{"Jane", "Citizen", "[email protected]"}) 
// neither does this
tx.NamedExec("INSERT INTO person (first_name, last_name, email) VALUES (@first_name, @last_name, @email)", &Person{"Jane", "Citizen", "[email protected]"}) 

there is this issue jmoiron/sqlx#374 regarding this problem but it doesn't seem to be active.

The second problem is that sqlserver doesn't support the usual LIMIT and OFFSET syntax so i would need to somehow override the buildPaginationClauses function...

Any ideas how this could be solved?

from pop.

markbates avatar markbates commented on July 17, 2024

You probably need to implement your own TranslateSQL function like Postgres does https://github.com/gobuffalo/pop/blob/master/postgresql.go

from pop.

marpio avatar marpio commented on July 17, 2024

I did that but the problem is, sqlx can not map to the fields in an struct, if i pass the params in form '@field_name' instead of ':field_name' so things like:
tx.NamedExec("INSERT INTO person (first_name, last_name, email) VALUES (@first_name, @last_name, @email)", &Person{"Jane", "Citizen", "[email protected]"})
sqlx does not recognize the '@field_name' and can't bind it.
this doesn't work either:

st, _ := tx.PrepareNamed("INSERT INTO person (first_name, last_name, email) VALUES (@first_name, @last_name, @email)")
st.Exec(&Person{"Jane", "Citizen", "[email protected]"})

from pop.

stanislas-m avatar stanislas-m commented on July 17, 2024

@marpio jmoiron/sqlx#406 was merged, and I just merged your PR in fizz. :)

from pop.

stanislas-m avatar stanislas-m commented on July 17, 2024

No problem, take your time!

from pop.

Norris1z avatar Norris1z commented on July 17, 2024

@marpio any update on this?

from pop.

marpio avatar marpio commented on July 17, 2024

@Norris1z
I'm quite busy these days and not sure when I get to it. Probably in 2-3 months. Sorry for that. Feel free to take this one if you're interested!

from pop.

andyedison avatar andyedison commented on July 17, 2024

I'm interesting in this. I'm a little green when it comes to Go, and would want to chat about what the scope of work looks like before volunteering to take this on. Gopher slack the best place for that?

from pop.

stanislas-m avatar stanislas-m commented on July 17, 2024

@andyedison Sure, feel free to join the buffalo-dev channel on Gopher slack. :)

from pop.

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.