gen icon indicating copy to clipboard operation
gen copied to clipboard

cannnot find exist tab,e

Open Jinrgan opened this issue 3 years ago • 2 comments

gen --sqltype=mssql \

  --connstr "sqlserver://sa:Developer1234@localhost:1433?database=QLS_CXData" \
  --database QLS_CXData \
  --exclude ReportingPoint  \
  --gorm

Warning - LoadMeta skipping table info for Field error: mssql: Invalid object name 'QLS_CXData.Field'. Warning - LoadMeta skipping table info for MetricsDataSet error: mssql: Invalid object name 'QLS_CXData.MetricsDataSet'. Skipping excluded table ReportingPoint No tables loaded

Jinrgan avatar May 25 '21 01:05 Jinrgan

I got this on the latest version v0.9.29 but it works for me on v0.9.27. I had to clone the repo, checkout v0.9.27 and then build it locally for it to work. (Also connecting to mssql as well)

dgoradia avatar May 27 '21 21:05 dgoradia

OK, thanks a lot. I tried this on v0.9.27, but it comes a small problem:

table: Field unable to generate struct field: ItemId type: UNIQUEIDENTIFIER error: unknown sql type: uniqueidentifier
Generating code for the following tables (1)

and it didn't seem to generate the element ItemId in this struct. Maybe this uniqueidentifier type can be converted to []byte type in go?

create table Field
(
    FieldId          int identity
        constraint Field_PK
            primary key,
    ReportingPointId int                        not null
        constraint Field_FK_ReportingPointId
            references ReportingPoint,
    ItemId           uniqueidentifier           not null,
    ItemFullName     nvarchar(450)              not null,
    Name             nvarchar(128)              not null,
    PreviousName     nvarchar(128),
    ColumnName       nvarchar(32),
    DataType         nvarchar(32)               not null,
    IsFilterable     bit                        not null,
    IsIndexed        bit
        constraint Field_DF_IsIndexed default 0 not null
)
type Field struct {
	//[ 0] FieldId                                        INT                  null: false  primary: true   isArray: false  auto: true   col: INT             len: -1      default: []
	FieldID int32 `gorm:"primary_key;AUTO_INCREMENT;column:FieldId;type:INT;"`
	//[ 1] ReportingPointId                               INT                  null: false  primary: false  isArray: false  auto: false  col: INT             len: -1      default: []
	ReportingPointID int32 `gorm:"column:ReportingPointId;type:INT;"`
	//[ 3] ItemFullName                                   NVARCHAR(900)        null: false  primary: false  isArray: false  auto: false  col: NVARCHAR        len: 900     default: []
	ItemFullName string `gorm:"column:ItemFullName;type:NVARCHAR;size:900;"`
	//[ 4] Name                                           NVARCHAR(256)        null: false  primary: false  isArray: false  auto: false  col: NVARCHAR        len: 256     default: []
	Name string `gorm:"column:Name;type:NVARCHAR;size:256;"`
	//[ 5] PreviousName                                   NVARCHAR(256)        null: true   primary: false  isArray: false  auto: false  col: NVARCHAR        len: 256     default: []
	PreviousName sql.NullString `gorm:"column:PreviousName;type:NVARCHAR;size:256;"`
	//[ 6] ColumnName                                     NVARCHAR(64)         null: true   primary: false  isArray: false  auto: false  col: NVARCHAR        len: 64      default: []
	ColumnName sql.NullString `gorm:"column:ColumnName;type:NVARCHAR;size:64;"`
	//[ 7] DataType                                       NVARCHAR(64)         null: false  primary: false  isArray: false  auto: false  col: NVARCHAR        len: 64      default: []
	DataType string `gorm:"column:DataType;type:NVARCHAR;size:64;"`
	//[ 8] IsFilterable                                   BIT                  null: false  primary: false  isArray: false  auto: false  col: BIT             len: -1      default: []
	IsFilterable bool `gorm:"column:IsFilterable;type:BIT;"`
	//[ 9] IsIndexed                                      BIT                  null: false  primary: false  isArray: false  auto: false  col: BIT             len: -1      default: [0]
	IsIndexed bool `gorm:"column:IsIndexed;type:BIT;default:0;"`
}

Jinrgan avatar May 30 '21 07:05 Jinrgan