Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MS SQL Server #40

Open
marpio opened this issue Mar 22, 2018 · 23 comments
Open

Support MS SQL Server #40

marpio opened this issue Mar 22, 2018 · 23 comments
Assignees
Labels
help wanted Feel free to contribute! proposal A suggestion for a change, feature, enhancement, etc s: accepted This proposal was accepted. Someone can start working on it.
Milestone

Comments

@marpio
Copy link

marpio commented Mar 22, 2018

It's an common DB in the enterprise and now also available for Linux.

@markbates
Copy link
Member

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

@marpio
Copy link
Author

marpio commented Mar 22, 2018

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

@markbates
Copy link
Member

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!

@marpio
Copy link
Author

marpio commented Mar 22, 2018

@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?

@markbates
Copy link
Member

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.

@marpio
Copy link
Author

marpio commented Mar 22, 2018

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

@markbates
Copy link
Member

markbates commented Mar 22, 2018 via email

@marpio
Copy link
Author

marpio commented Mar 22, 2018

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

@mclark4386
Copy link
Member

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

@marpio
Copy link
Author

marpio commented Mar 27, 2018

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

@markbates
Copy link
Member

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. :)

@marpio
Copy link
Author

marpio commented Mar 30, 2018

@markbates thanks

@marpio
Copy link
Author

marpio commented Apr 12, 2018

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", "jmoiron@jmoiron.net")
// this works
tx.MustExec("INSERT INTO person (first_name, last_name, email) VALUES (@p1, @p2, @p3)", "Jason", "Moiron", "jmoiron@jmoiron.net")

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

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?

@markbates
Copy link
Member

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

@markbates markbates reopened this Apr 12, 2018
@marpio
Copy link
Author

marpio commented Apr 13, 2018

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", "jane.citzen@example.com"})
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", "jane.citzen@example.com"})

@marpio
Copy link
Author

marpio commented Apr 16, 2018

Waiting for jmoiron/sqlx#406

@stanislas-m stanislas-m added proposal A suggestion for a change, feature, enhancement, etc and removed WIP proposal A suggestion for a change, feature, enhancement, etc labels Oct 31, 2018
@stanislas-m
Copy link
Member

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

@marpio
Copy link
Author

marpio commented Nov 10, 2018

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

@stanislas-m
Copy link
Member

No problem, take your time!

@stanislas-m stanislas-m added the s: accepted This proposal was accepted. Someone can start working on it. label Dec 3, 2018
@Norris1z
Copy link

@marpio any update on this?

@marpio
Copy link
Author

marpio commented May 13, 2019

@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!

@stanislas-m stanislas-m added the help wanted Feel free to contribute! label Aug 30, 2019
@andyedison
Copy link

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?

@stanislas-m
Copy link
Member

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

@sio4 sio4 added this to the Proposal milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Feel free to contribute! proposal A suggestion for a change, feature, enhancement, etc s: accepted This proposal was accepted. Someone can start working on it.
Projects
None yet
Development

No branches or pull requests

7 participants