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

error: sql: Scan error on column index 0: unsupported driver -> Scan pair: <nil> -> *string #16

Closed
whitebook opened this issue May 16, 2016 · 11 comments

Comments

@whitebook
Copy link

Using MSSQL Driver from https://github.com/denisenkom/go-mssqldb.git

Getting this trying this from CLI.

xo mssql://user:pass@host:1433/db -o models -N -M -B -T Match << ENDSQL
select * from match ;
ENDSQL

error: sql: Scan error on column index 0: unsupported driver -> Scan pair: -> *string

Is there another driver I should be using?

Thanks.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

Can you provide me some more information about the schema for the match table? If the mssqldb package doesn't support the underlying SQL type, there's not much that can be done but add support for it in that package.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

I also just realized there may be an issue with the type recognition in xo. I have not tested MS SQL Server much, as it's the most difficult to test as I have to deal with a constantly broken VirtualBox VM and Windows.

@whitebook
Copy link
Author

whitebook commented May 16, 2016

username (varchar)
firstname (varchar)
lastname (varchar)
title (varchar)
passwrd (varchar)
email (varchar)
spouse (varchar)
home_phone (varchar)
work_phone (varchar)
mobile (varchar)
address (varchar)
city (varchar)
state (varchar)
province (varchar)
zip (varchar)
describe_whuy_you_want_be_matchmaker (text)
experience_in_matchmaking (varchar)
describe_experinect (text)
country_origin (varchar)
memberstatus (varchar)
refname1 (varchar)
refnumber1 (varchar)
refrelation1 (varchar)
refname2 (varchar)
refnumber2 (varchar)
refrelation2 (varchar)
condition_mustmarried (varchar)
condition_commit_min_hours (varchar)
condition_deviation_bylaw (varchar)
condtion_option_know_member (varchar)
condition_may_contactus_training (varchar)
condition_network_community (varchar)
condition_information_confidential (varchar)
condition_matches_made (varchar)
is_active (varchar)
is_delete (varchar)
last_login (datetime)
reg_date (datetime)

(Not really a windows user either. I was hoping I could use this tool to Migrate this DB to Postgres...)

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

Could you please provide the full create table statement? Also, can you make sure you have the latest code for the mssqldb package, and can you tell me what version of Microsoft SQL Server you're using?

In the meantime, I'll try to create a table with these fields on the only version of SQL Server I've been testing against, which is SQL Express '14.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

I created the schema using this:

drop table testtab;

CREATE TABLE testtab (
username varchar(255) NOT NULL DEFAULT '',
firstname varchar(255) NOT NULL DEFAULT '',
lastname varchar(255) NOT NULL DEFAULT '',
title varchar(255) NOT NULL DEFAULT '',
passwrd varchar(255) NOT NULL DEFAULT '',
email varchar(255) NOT NULL DEFAULT '',
spouse varchar(255) NOT NULL DEFAULT '',
home_phone varchar(255) NOT NULL DEFAULT '',
work_phone varchar(255) NOT NULL DEFAULT '',
mobile varchar(255) NOT NULL DEFAULT '',
address varchar(255) NOT NULL DEFAULT '',
city varchar(255) NOT NULL DEFAULT '',
state varchar(255) NOT NULL DEFAULT '',
province varchar(255) NOT NULL DEFAULT '',
zip varchar(255) NOT NULL DEFAULT '',
describe_whuy_you_want_be_matchmaker varchar(255) NOT NULL DEFAULT '',
experience_in_matchmaking varchar(255) NOT NULL DEFAULT '',
describe_experinect varchar(255) NOT NULL DEFAULT '',
country_origin varchar(255) NOT NULL DEFAULT '',
memberstatus varchar(255) NOT NULL DEFAULT '',
refname1 varchar(255) NOT NULL DEFAULT '',
refnumber1 varchar(255) NOT NULL DEFAULT '',
refrelation1 varchar(255) NOT NULL DEFAULT '',
refname2 varchar(255) NOT NULL DEFAULT '',
refnumber2 varchar(255) NOT NULL DEFAULT '',
refrelation2 varchar(255) NOT NULL DEFAULT '',
condition_mustmarried varchar(255) NOT NULL DEFAULT '',
condition_commit_min_hours varchar(255) NOT NULL DEFAULT '',
condition_deviation_bylaw varchar(255) NOT NULL DEFAULT '',
condtion_option_know_member varchar(255) NOT NULL DEFAULT '',
condition_may_contactus_training varchar(255) NOT NULL DEFAULT '',
condition_network_community varchar(255) NOT NULL DEFAULT '',
condition_information_confidential varchar(255) NOT NULL DEFAULT '',
condition_matches_made varchar(255) NOT NULL DEFAULT '',
is_active varchar(255) NOT NULL DEFAULT '',
is_delete varchar(255) NOT NULL DEFAULT '',
last_login datetime NOT NULL DEFAULT current_timestamp,
reg_date datetime NOT NULL DEFAULT current_timestamp
);

The issue is that the xo code for MS SQL isn't correctly detecting that a 'nullable' string should be of type sql.NullString and not string. I'll look into this and try to figure out where the problem is.

@whitebook
Copy link
Author

I am using the latest mssql driver from git master.
I think the server is MSSQL 2012 Express Edition.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

I see what the issue is. I need to tweak the underlying SQL that xo uses to retrieve index information from MS SQL. I should have it fixed shortly. Sorry for the problem. Unfortunately, I work primarily in an environment that uses Oracle/PostgreSQL and because MS hasn't released their SQL server for Linux yet, it gets the least amount of attention. Hopefully that changes with SQL Server '16 for Linux.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

I just pushed a change that should fix this issue. Please note that I would highly recommend that you have some kind of primary keys or indexes defined on your table! Please test this and let me know if that resolves the issue for you. Thanks!

@whitebook
Copy link
Author

Just ran "go get -u github.com/knq/xo"

Tried again, still getting the same result. Perhaps its coming from somewhere else as well?

Maybe I missed updating something else?

Thanks.

@kenshaw
Copy link
Member

kenshaw commented May 16, 2016

I used the schema that I posted above. It works without any problems here. Can you post the schema you're using? Thanks.

@kenshaw kenshaw reopened this May 16, 2016
@kenshaw
Copy link
Member

kenshaw commented May 22, 2016

I'm closing this issue again since there has been no response. If you continue to have issues with SQL Server, please open a new issue and I will address the problem. Thanks!

@kenshaw kenshaw closed this as completed May 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants