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

Adding mssql support. #3772

Merged
merged 1 commit into from
Feb 14, 2017
Merged

Adding mssql support. #3772

merged 1 commit into from
Feb 14, 2017

Conversation

dlob
Copy link
Contributor

@dlob dlob commented Oct 16, 2016

This pull request adds support for mssql (Microsoft SQL Server) databases.

It depends on a pull request to xorm (go-xorm/xorm#469), which is mandatory to get mssql support for gogs without fundamental changes.

@btrepp
Copy link

btrepp commented Nov 29, 2016

Rebased onto master, when editing LDAP authentication configuration it gives a 500 internal server error, logs show

[...uters/admin/auths.go:228 EditAuthSourcePost()] [E] UpdateSource: mssql: Operand type clash: varbinary is incompatible with text

Workaround is editing the JSON in the table directly.

With an organization created, viewing the dashboard gives

2016/11/29 11:01:26 [...routers/user/home.go:117 Dashboard()] [E] GetUserRepositories: get repositories: mssql: Incorrect syntax near 'LIMIT'.

@btrepp
Copy link

btrepp commented Nov 29, 2016

For the second part, It appears xorm doesn't transparently shift between LIMIT/TOP, as limit is not supported in SQL server. Not knowing xorm/go very well, should an issue be raised there?, or is it the responsibility of gogs to detect the DB and translate queries?.

EDIT: I was wrong. Apparently gogs is using raw SQL in models/org.go:497. This section uses a hardcoded LIMIT query. (With a todo suggestion using the xorm builder)

@dlob
Copy link
Contributor Author

dlob commented Nov 29, 2016

@btrepp The first issue should be solved by this pull request to xorm: #499.

@btrepp
Copy link

btrepp commented Nov 29, 2016

@dlob.! awesome.

From my testing the only other issue is the hardcoded limit expression, which is an easy change for someone who knows xorm.

Everything else I've encountered are already tracked/not related to mssql support.

EDIT: I tried cloning the changes to xorm and rebuilding, the error still occurs in gogs.

@dlob
Copy link
Contributor Author

dlob commented Nov 30, 2016

@btrepp Did you create a new database? The fix does not work with already existing dbs out of the box, because the type definition of the 'cfg' column of the 'login_source' table has changed to varchar(max) instead of text. Otherwise you could do this change manually.

@lunny
Copy link
Contributor

lunny commented Dec 1, 2016

Hi, I have merged go-xorm/xorm#499 and push some commits for mssql support.
Limit has been supported by XORM. You should use Limit(limit, start).
Could you also send a PR to github.com/go-gitea/gitea ?

@unknwon unknwon added the status: waits for review It is waiting to be reviewed by maintainers label Dec 24, 2016
@johnharris85
Copy link

Any update on whether this is going to get merged?

@unknwon
Copy link
Member

unknwon commented Feb 1, 2017

@johnharris85 I have to install a SQL server to test it, not easy on a Mac, need download and setup a Windows.

@johnharris85
Copy link

OK cool. I might be able to help in the next day or so (on Linux but have a Windows box hanging around somewhere I'm sure).

@unknwon unknwon added this to the 0.10.0 milestone Feb 1, 2017
@Corben78
Copy link
Contributor

Corben78 commented Feb 1, 2017

@johnharris85: mssql is also available for Linux if that helps.
For testing on macOS you would have to use Docker.

@unknwon
Copy link
Member

unknwon commented Feb 10, 2017

I'm using MSSQL for Linux and failed with:

2017/02/10 03:02:59 [FATAL] [...om/urfave/cli/app.go:483 HandleAction()] Fail to initialize ORM engine: sync database struct error: Unknown colType SYSNAME for MSreplication_options - optname

@unknwon unknwon added the status: needs feedback Tell me more about it label Feb 10, 2017
@unknwon unknwon removed this from the 0.10.0 milestone Feb 10, 2017
@dlob
Copy link
Contributor Author

dlob commented Feb 13, 2017

@unknwon Did you create a database first? I was able to reproduce the error when no database has been created and mssql uses the default 'master' database.

If you create a database (e.g. 'gogs'), it works. I tested this also with MSSQL for Linux running inside Docker.

There is definitely a need of improvement regarding error handling and error messages in xorm/mssql-driver.

@unknwon
Copy link
Member

unknwon commented Feb 13, 2017

Ah.. stupid me! I'll test again. 😓

@unknwon
Copy link
Member

unknwon commented Feb 14, 2017

Succeed.

BTW, any recommendations of Mac MSSQL client?

@unknwon unknwon merged commit 5179063 into gogs:develop Feb 14, 2017
@unknwon unknwon removed the status: needs feedback Tell me more about it label Feb 14, 2017
unknwon added a commit that referenced this pull request Feb 14, 2017
@dlob
Copy link
Contributor Author

dlob commented Feb 14, 2017

@unknwon I only know this one: https://docs.microsoft.com/en-us/sql/connect/odbc/linux/connecting-with-sqlcmd
But I'm not sure if it also runs on mac. But at least it should run inside a Docker container.

@unknwon
Copy link
Member

unknwon commented Feb 14, 2017

Thanks for the link! But I wasn't clear about my question... I'll try google with some GUI clients...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: waits for review It is waiting to be reviewed by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants