@@ -47,9 +47,17 @@ type Config interface {
4747 ) (map [string ]map [string ]interface {}, map [int ]map [int ]interface {})
4848 GetCurrentTable (internaldto.HeirarchyIdentifiers ) (internaldto.DBTable , error )
4949 GetRelationalType (string ) string
50- GenerateDDL (util.AnnotatedTabulation , anysdk.Provider ,
51- anysdk.Service , anysdk.Resource , anysdk.StandardOperationStore , bool ,
52- int , bool , bool ) ([]string , error )
50+ GenerateDDL (
51+ util.AnnotatedTabulation ,
52+ anysdk.Provider ,
53+ anysdk.Service ,
54+ anysdk.Resource ,
55+ anysdk.StandardOperationStore ,
56+ bool ,
57+ int ,
58+ bool ,
59+ bool ,
60+ ) ([]string , error )
5361 GetControlAttributes () sqlcontrol.ControlAttributes
5462 GetGolangValue (string ) interface {}
5563 GetGolangSlices ([]typing.ColumnMetadata ) ([]interface {}, []string )
@@ -59,13 +67,20 @@ type Config interface {
5967 GetTable (internaldto.HeirarchyIdentifiers , int ) (internaldto.DBTable , error )
6068 GenerateInsertDML (
6169 util.AnnotatedTabulation ,
62- anysdk.OperationStore ,
70+ anysdk.Provider ,
71+ anysdk.Service ,
72+ anysdk.Resource ,
73+ anysdk.StandardOperationStore ,
6374 internaldto.TxnControlCounters ,
6475 bool ,
6576 bool ,
6677 ) (PreparedStatementCtx , error )
6778 GenerateSelectDML (
6879 util.AnnotatedTabulation ,
80+ anysdk.Provider ,
81+ anysdk.Service ,
82+ anysdk.Resource ,
83+ anysdk.StandardOperationStore ,
6984 internaldto.TxnControlCounters ,
7085 string ,
7186 string ,
@@ -453,6 +468,49 @@ func (dc *staticDRMConfig) genRelationalTableFromExternalSQLTable(
453468 return relationalTable , nil
454469}
455470
471+ func (dc * staticDRMConfig ) obtainAddressSpace (
472+ prov anysdk.Provider ,
473+ svc anysdk.Service ,
474+ resource anysdk.Resource ,
475+ m anysdk.StandardOperationStore ,
476+ isAwait bool ,
477+ ) (anysdk.AddressSpace , error ) {
478+ addressSpaceFormulator := radix_tree_address_space .NewAddressSpaceFormulator (
479+ radix_tree_address_space .NewAddressSpaceGrammar (),
480+ prov ,
481+ svc ,
482+ resource ,
483+ m ,
484+ m .GetProjections (),
485+ isAwait ,
486+ )
487+ addressSpaceErr := addressSpaceFormulator .Formulate ()
488+ if addressSpaceErr != nil {
489+ return nil , addressSpaceErr
490+ }
491+ // TODO: use address space
492+ addressSpace := addressSpaceFormulator .GetAddressSpace ()
493+ if addressSpace == nil {
494+ return nil , fmt .Errorf ("failed to obtain address space" )
495+ }
496+ return addressSpace , nil
497+ }
498+
499+ func (dc * staticDRMConfig ) obtainRelationFromAddressSpace (
500+ addressSpace anysdk.AddressSpace ,
501+ isNilResponseAllowed bool ,
502+ ) (anysdk.Relation , error ) {
503+ inferredRelation , inferredRelationErr := addressSpace .ToRelation (
504+ radix_tree_address_space .NewStandardAddressSpaceExpansionConfig (
505+ true , // TODO: switch this off at the appropriate time
506+ isNilResponseAllowed ,
507+ ))
508+ if inferredRelationErr != nil {
509+ return nil , inferredRelationErr
510+ }
511+ return inferredRelation , nil
512+ }
513+
456514func (dc * staticDRMConfig ) genRelationalTable (
457515 tabAnn util.AnnotatedTabulation ,
458516 prov anysdk.Provider ,
@@ -461,7 +519,7 @@ func (dc *staticDRMConfig) genRelationalTable(
461519 m anysdk.StandardOperationStore ,
462520 isAwait bool ,
463521 discoveryGenerationID int ,
464- isNilResponseAlloed bool ,
522+ isNilResponseAllowed bool ,
465523) (relationaldto.RelationalTable , error ) {
466524 tableName , err := dc .getTableName (tabAnn .GetHeirarchyIdentifiers (), discoveryGenerationID )
467525 if err != nil {
@@ -479,30 +537,12 @@ func (dc *staticDRMConfig) genRelationalTable(
479537 )
480538 addressSpace , hasAddressSpace := m .GetAddressSpace ()
481539 if ! hasAddressSpace {
482- addressSpaceFormulator := radix_tree_address_space .NewAddressSpaceFormulator (
483- radix_tree_address_space .NewAddressSpaceGrammar (),
484- prov ,
485- svc ,
486- resource ,
487- m ,
488- m .GetProjections (),
489- isAwait ,
490- )
491- addressSpaceErr := addressSpaceFormulator .Formulate ()
492- if addressSpaceErr != nil {
493- return nil , addressSpaceErr
494- }
495- // TODO: use address space
496- addressSpace = addressSpaceFormulator .GetAddressSpace ()
497- if addressSpace == nil {
498- return nil , fmt .Errorf ("failed to obtain address space" )
540+ addressSpace , err = dc .obtainAddressSpace (prov , svc , resource , m , isAwait )
541+ if err != nil {
542+ return nil , err
499543 }
500544 }
501- inferredRelation , inferredRelationErr := addressSpace .ToRelation (
502- radix_tree_address_space .NewStandardAddressSpaceExpansionConfig (
503- true , // TODO: switch this off at the appropriate time
504- isNilResponseAlloed ,
505- ))
545+ inferredRelation , inferredRelationErr := dc .obtainRelationFromAddressSpace (addressSpace , isNilResponseAllowed )
506546 if inferredRelationErr != nil {
507547 return nil , inferredRelationErr
508548 }
@@ -528,10 +568,10 @@ func (dc *staticDRMConfig) GenerateDDL(
528568 isAwait bool ,
529569 discoveryGenerationID int ,
530570 dropTable bool ,
531- isNilResponseAlloed bool ,
571+ isNilResponseAllowed bool ,
532572) ([]string , error ) {
533573 relationalTable , err := dc .genRelationalTable (
534- tabAnn , prov , svc , resource , m , isAwait , discoveryGenerationID , isNilResponseAlloed )
574+ tabAnn , prov , svc , resource , m , isAwait , discoveryGenerationID , isNilResponseAllowed )
535575 if err != nil {
536576 return nil , err
537577 }
@@ -541,9 +581,12 @@ func (dc *staticDRMConfig) GenerateDDL(
541581//nolint:gocritic,govet // defer fix
542582func (dc * staticDRMConfig ) GenerateInsertDML (
543583 tabAnnotated util.AnnotatedTabulation ,
544- method anysdk.OperationStore ,
584+ prov anysdk.Provider ,
585+ svc anysdk.Service ,
586+ resource anysdk.Resource ,
587+ method anysdk.StandardOperationStore ,
545588 tcc internaldto.TxnControlCounters ,
546- isNilResponseAlloed bool ,
589+ isNilResponseAllowed bool ,
547590 isAsync bool ,
548591) (PreparedStatementCtx , error ) {
549592 var columns []typing.ColumnMetadata
@@ -588,11 +631,18 @@ func (dc *staticDRMConfig) GenerateInsertDML(
588631 relationalTable .PushBackColumn (col )
589632 }
590633 } else {
591- schemaAnalyzer := util .NewTableSchemaAnalyzer (tabAnnotated .GetTabulation ().GetSchema (), method , isNilResponseAlloed )
592- tableColumns , err := schemaAnalyzer .GetColumnDescriptors (tabAnnotated )
593- if err != nil && ! isNilResponseAlloed {
594- return nil , err
634+ addressSpace , addressSpaceErr := dc .obtainAddressSpace (prov , svc , resource , method , isAsync )
635+ if addressSpaceErr != nil {
636+ return nil , addressSpaceErr
595637 }
638+ inferredRelation , relationErr := dc .obtainRelationFromAddressSpace (
639+ addressSpace ,
640+ isNilResponseAllowed ,
641+ )
642+ if relationErr != nil {
643+ return nil , relationErr
644+ }
645+ tableColumns := inferredRelation .GetColumnDescriptors ()
596646 for _ , col := range tableColumns {
597647 relationalType := textStr
598648 schema := col .GetSchema ()
@@ -636,6 +686,10 @@ func (dc *staticDRMConfig) GenerateInsertDML(
636686
637687func (dc * staticDRMConfig ) GenerateSelectDML (
638688 tabAnnotated util.AnnotatedTabulation ,
689+ prov anysdk.Provider ,
690+ svc anysdk.Service ,
691+ resource anysdk.Resource ,
692+ method anysdk.StandardOperationStore ,
639693 txnCtrlCtrs internaldto.TxnControlCounters ,
640694 selectSuffix ,
641695 rewrittenWhere string ,
0 commit comments