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

expected operand, found 'type' #361

Open
runar-rkmedia opened this issue May 25, 2022 · 0 comments
Open

expected operand, found 'type' #361

runar-rkmedia opened this issue May 25, 2022 · 0 comments

Comments

@runar-rkmedia
Copy link

Tried this tool today with a big mssql database, but ran into some trouble. Perhaps this is a bit out of scope here, because of the size of the database, and it probably includes a whole lot of strange stuff created over many years, but I'll try posting this here in any case.

 xo schema mssql://<connectionstring-o models

error: sp_prvigetseriesnew.xo.go:29:174: expected operand, found 'type'
error: 1 errors encountered

Tried with debugging (which I see from the documentation that it drop post processing)

 xo schema mssql://<connectionstring-o models

That works. I tried building this, just to see where the error is:

go build ./models/*

models/sp_prvigetseriesnew.xo.go:29:174: syntax error: unexpected type, expecting expression
models/sp_prvigetseriesnew.xo.go:30:3: syntax error: unexpected return, expecting expression
models/sp_prvigetseriesnew.xo.go:32:2: syntax error: non-declaration statement outside function body

the file referenced in the error above:

package models

// Code generated by xo. DO NOT EDIT.

import (
	"context"
	"database/sql"
	"database/sql/driver"
	"encoding/csv"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"regexp"
	"strings"
	"time"
	"github.com/google/uuid"

)
// PrVIGetSeriesNew calls the stored procedure 'DBNAME.pr_VI_GetSeries_New() (varchar, varchar, char)' on db.
func PrVIGetSeriesNew(ctx context.Context, db DB, ) (string, string, string, error) {
	// call DBNAME.pr_VI_GetSeries_New
	const sqlstr = `DBNAME.pr_VI_GetSeries_New`
	// run
	var mainNumber string
	var series string
	var typ string
	logf(sqlstr, )
	if _, err := db.ExecContext(ctx, sqlstr, sql.Named("MainNumber", sql.Out{Dest: &mainNumber}), sql.Named("Series", sql.Out{Dest: &series}), sql.Named("Type", sql.Out{Dest: &type})); err != nil {
		return "", "", "", logerror(err)
	}
	return mainNumber, series, typ, nil
}

Looks the the variable Type conflicts with the the reserved word type.

After fixing that manually, I got a set a new errors:

models/sp_devmbnpssetfailed.xo.go:33:6: DevMbnpsSetFailed redeclared in this block
models/sp_devmbnpssetfailed.xo.go:21:6: other declaration of DevMbnpsSetFailed
models/sp_prcustomergetraw.xo.go:33:6: PrCustomerGetRaw redeclared in this block
models/sp_prcustomergetraw.xo.go:21:6: other declaration of PrCustomerGetRaw
models/sp_prcontractproductupdatecpcn.xo.go:27:77: error (type) is not an expression
models/sp_prcustomernumberbillingchangealias.xo.go:27:77: error (type) is not an expression
models/sp_prcustomernumberbillingchangenumberinvoice.xo.go:27:77: error (type) is not an expression
models/sp_prcustomernumberbillingchangepricelist.xo.go:27:77: error (type) is not an expression
models/sp_prcustomerupdateaddress.xo.go:27:77: error (type) is not an expression
models/sp_prcustomerupdateaddressnew.xo.go:27:77: error (type) is not an expression
models/sp_prlinkproviderimsisearch.xo.go:27:77: error (type) is not an expression
models/sp_prlinkprovidersimsearch.xo.go:27:77: error (type) is not an expression
models/sp_prlinkprovidersimsearch.xo.go:27:77: too many errors

the file _prcustomernumberbillingchangenumberinvoice.xo.go, errors with the same kind, the reserved word error:

	var e int
	logf(sqlstr, )
	if _, err := db.ExecContext(ctx, sqlstr, sql.Named("Error", sql.Out{Dest: &error})); err != nil {
		return 0, logerror(err)
	}

the file sp_devmbnpssetfailed.xo.go seems to have generated the same contents twice:

// DevMbnpsSetFailed calls the stored procedure 'DBNAME.dev_mbnps_setFailed()' on db.
func DevMbnpsSetFailed(ctx context.Context, db DB, ) (error) {
	// call DBNAME.dev_mbnps_setFailed
	const sqlstr = `DBNAME.dev_mbnps_setFailed`
	// run
	logf(sqlstr)
	if _, err := db.ExecContext(ctx, sqlstr, ); err != nil {
		return logerror(err)
	}
	return nil
}

// DevMbnpsSetFailed calls the stored procedure 'DBNAME.dev_mbnps_setFailed()' on db.
func DevMbnpsSetFailed(ctx context.Context, db DB, ) (error) {
	// call DBNAME.dev_mbnps_setFailed
	const sqlstr = `DBNAME.dev_mbnps_setFailed`
	// run
	logf(sqlstr)
	if _, err := db.ExecContext(ctx, sqlstr, ); err != nil {
		return logerror(err)
	}
	return nil
}

same goes for the models/sp_prcustomergetraw.x.go

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

1 participant