@@ -3,7 +3,7 @@ package ingest
33import (
44 "fmt"
55 "github.com/microsoft/go-sqlcmd/internal/container"
6- "github.com/microsoft/go-sqlcmd/internal/uri "
6+ "github.com/microsoft/go-sqlcmd/internal/databaseurl "
77 "github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer/ingest/extract"
88 "github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer/ingest/location"
99 "github.com/microsoft/go-sqlcmd/pkg/mssqlcontainer/ingest/mechanism"
@@ -12,7 +12,7 @@ import (
1212)
1313
1414type ingest struct {
15- uri uri. Uri
15+ uri * databaseurl. DatabaseUrl
1616 location location.Location
1717 controller * container.Controller
1818 mechanism mechanism.Mechanism
@@ -23,7 +23,7 @@ type ingest struct {
2323}
2424
2525func (i * ingest ) IsExtractionNeeded () bool {
26- i .extractor = extract .NewExtractor (i .uri .FileExtension () , i .controller )
26+ i .extractor = extract .NewExtractor (i .uri .FileExtension , i .controller )
2727 if i .extractor == nil {
2828 return false
2929 } else {
@@ -36,12 +36,12 @@ func (i *ingest) IsRemoteUrl() bool {
3636}
3737
3838func (i * ingest ) UrlFilename () string {
39- return i .uri .Filename ()
39+ return i .uri .Filename
4040}
4141
4242func (i * ingest ) IsValidScheme () bool {
4343 for _ , s := range i .location .ValidSchemes () {
44- if s == i .uri .Scheme () {
44+ if s == i .uri .Scheme {
4545 return true
4646 }
4747 }
@@ -59,7 +59,7 @@ func (i *ingest) CopyToContainer(containerId string) {
5959
6060 i .containerId = containerId
6161 i .location .CopyToContainer (containerId , destFolder )
62- i .options .Filename = i .uri .Filename ()
62+ i .options .Filename = i .uri .Filename
6363
6464 if i .options .Filename == "" {
6565 panic ("filename is empty" )
@@ -76,7 +76,7 @@ func (i *ingest) Extract() {
7676 }
7777
7878 i .options .Filename , i .options .LdfFilename =
79- i .extractor .Extract (i .uri .Filename () , "/var/opt/mssql/data" )
79+ i .extractor .Extract (i .uri .Filename , "/var/opt/mssql/data" )
8080
8181 if i .mechanism == nil {
8282 ext := strings .TrimLeft (filepath .Ext (i .options .Filename ), "." )
@@ -88,11 +88,18 @@ func (i *ingest) BringOnline(query func(string), username string, password strin
8888 if i .options .Filename == "" {
8989 panic ("filename is empty, did you call CopyToContainer()?" )
9090 }
91+ if query == nil {
92+ panic ("query is nil" )
93+ }
94+ if i .mechanism == nil {
95+ panic ("mechanism is nil" )
96+ }
9197
9298 i .query = query
9399 i .options .Username = username
94100 i .options .Password = password
95- i .mechanism .BringOnline (i .uri .GetDbNameAsIdentifier (), i .containerId , i .query , i .options )
101+ fmt .Println (i .uri .DatabaseNameAsTsqlIdentifier )
102+ i .mechanism .BringOnline (i .uri .DatabaseNameAsTsqlIdentifier , i .containerId , i .query , i .options )
96103 i .setDefaultDatabase (username )
97104}
98105
@@ -104,18 +111,18 @@ func (i *ingest) setDefaultDatabase(username string) {
104111 alterDefaultDb := fmt .Sprintf (
105112 "ALTER LOGIN [%s] WITH DEFAULT_DATABASE = [%s]" ,
106113 username ,
107- i .uri .GetDbNameAsNonIdentifier () )
114+ i .uri .DatabaseNameAsNonTsqlIdentifier )
108115 i .query (alterDefaultDb )
109116}
110117
111118func (i * ingest ) IsValidFileExtension () bool {
112119 for _ , m := range mechanism .FileTypes () {
113- if m == i .uri .FileExtension () {
120+ if m == i .uri .FileExtension {
114121 return true
115122 }
116123 }
117124 for _ , e := range extract .FileTypes () {
118- if e == i .uri .FileExtension () {
125+ if e == i .uri .FileExtension {
119126 return true
120127 }
121128 }
@@ -127,7 +134,7 @@ func (i *ingest) SourceFileExists() bool {
127134}
128135
129136func (i * ingest ) UserProvidedFileExt () string {
130- return i .uri .FileExtension ()
137+ return i .uri .FileExtension
131138}
132139
133140func (i * ingest ) ValidSchemes () []string {
0 commit comments