@@ -275,8 +275,6 @@ function util_id2entity(ptype::DataType,
275275 return missing
276276 end
277277
278- @info " Convert a $ptype using id_values[$id_values ]"
279-
280278 complex_prop = ptype ()
281279 id_properties = util_get_ids_props_names (complex_prop)
282280
@@ -335,8 +333,6 @@ function util_dict2entity(props_dict::Dict{Symbol,T},
335333 retrieve_complex_props:: Bool ,
336334 dbconn:: Union{LibPQ.Connection,Missing} ) where T <: Any
337335
338- println (" props_dict" , props_dict)
339-
340336 # Clone the Dict to make sure that it is of type Dict{Symbol, Any} so that we
341337 # can for example replace a value by another one of different type
342338 props_dict = Dict {Symbol,Any} (props_dict)
@@ -699,7 +695,6 @@ function util_convert_flatdictfromdb_to_structuredrenameddict(
699695 break
700696 end
701697 end
702- @info " $propname all_cols_found[$all_cols_found ] missing_cols[$missing_cols ]"
703698
704699 # If all values for building the entity are found, build it and add to result list
705700 if all_cols_found
@@ -724,105 +719,6 @@ function util_convert_flatdictfromdb_to_structuredrenameddict(
724719
725720end
726721
727- function util_convert_flatdictfromdb_to_structuredrenameddict_DEPRECATED (
728- flatdict:: Dict ,
729- object_type:: DataType ,
730- dbconn:: Union{LibPQ.Connection,Missing}
731- )
732- sample_object = object_type ()
733- orm_module = get_orm (sample_object)
734-
735- result = Dict ()
736-
737- # Loop over the properties of the struct and try to get the corresponding
738- # values in the flat dict
739- for (propname,prop_colnames) in util_get_columns_selection_and_mapping (orm_module)
740-
741- # Get the proptype in order to know if we are dealing with a complex
742- # property or not
743- proptype = util_get_property_real_type (object_type, propname)
744-
745- # if the property is a complex prop we build a dict with the IDs of
746- # the complex object as described in the ORM of the complex property
747- if proptype <: IEntity
748-
749- result[propname] = Dict ()
750-
751- # Retrieve the type of the complex object
752- complexprop_instance = proptype ()
753- complexprop_idprops = util_get_ids_props_names (complexprop_instance)
754- complexprop_orm = get_orm (complexprop_instance)
755-
756- # Check that the number of columns for the FK is consistent with
757- # the number of properties used as PK in the targeted object
758- if length (complexprop_idprops) != length (tovector (prop_colnames))
759- error (" There is an inconsistency in the ORMs definition,
760- type[$object_type ] has property[$propname ] of type[$proptype ]
761- which is mapped with $(length (tovector (prop_colnames))) columns
762- but type[$proptype ] has only $(length (complexprop_idprops)) IDs
763- properties" )
764- end
765-
766- # If there is a composed foreign key we need to correctly map the
767- # column values to the column ids in the target table
768- if propname == :document
769- @info " prop_colnames" prop_colnames
770- end
771- if isa (prop_colnames, Array) && length (prop_colnames) > 1
772-
773- # Loop over the FK columns and use the PKs in the same order
774- # TODO : Handle the case where the order of the FKs and PKs columns
775- # is not the same
776- counter = 0
777- for colname in prop_colnames
778-
779- if propname == :document
780- @info " colname" colname
781- end
782-
783- # Get the value from the flatdict (if exists)
784- if haskey (flatdict, Symbol (colname))
785- colvalue = flatdict[Symbol (colname)]
786- # If one of the components is missing we break here because we are not
787- # interested in just a portion of the id
788- else
789- break
790- end
791-
792- complexprop_idprop = complexprop_idprops[counter+= 1 ]
793- result[propname][complexprop_idprop] = colvalue
794-
795-
796- end
797-
798- # If it is a non componsed foreign key then we can simply use the
799- # id property of the targeted object
800- else
801- complexprop_idprop = complexprop_idprops[1 ]
802- complexprop_colname = Symbol (tovector (prop_colnames)[1 ])
803- if haskey (flatdict, complexprop_colname)
804- result[propname][complexprop_idprop] = flatdict[complexprop_colname]
805- end
806-
807- end # ENFOF `if isa(prop_colnames, Array) && length(prop_colnames) > 1`
808-
809-
810-
811- # If the property is simple then we just look for the value in the dict
812- else
813- colname = Symbol (tovector (prop_colnames)[1 ])
814- if haskey (flatdict,colname)
815- result[propname] = flatdict[colname]
816- end
817- end # ENDOF `if proptype <: IEntity`
818-
819- end # ENDOF `for (propname,prop_colnames) in util_get_columns_selection_and_mapping(orm_module)`
820-
821- return result
822-
823-
824- end
825-
826722# Create the selection as expected by the Query.jl macro
827723# Eg: `{id = i.document_id, lastname = i.lastname}` )
828724function util_get_curlybrackets_expression_for_linq_select (
@@ -910,12 +806,6 @@ function util_replace_complex_types_by_id(props::Dict, mapping::Dict, data_type:
910806 referenced_col_to_referencing_col[referenced_col] = referencing_col
911807 end
912808
913- if prop_symbol == :document
914- @info " referenced_col_to_referencing_col" referenced_col_to_referencing_col
915- end
916-
917- # @info "Replace[$prop_symbol] with ids"
918-
919809 dummy_propval = _fieldtype () # Used in case the prop val is missing
920810
921811 prop_orm_module = get_orm (_fieldtype ())
@@ -925,15 +815,9 @@ function util_replace_complex_types_by_id(props::Dict, mapping::Dict, data_type:
925815 # Retrieve the names of the ID properties in the target struct
926816 id_props_in_target_struct = util_get_ids_props_names (_fieldtype ())
927817
928- # @info "id_props_in_target_struct[$id_props_in_target_struct] ($_fieldtype)"
929-
930818 # Whatever we get from the mapping we make it a vector
931819 idcols = tovector (mapping[prop_symbol])
932820
933- if prop_symbol == :document
934- @info " idcols" idcols
935- end
936-
937821 prop_val_as_dict =
938822 PostgresORMUtil. getproperties_asdict (
939823 if ismissing (prop_val) dummy_propval else prop_val end ,
@@ -944,22 +828,13 @@ function util_replace_complex_types_by_id(props::Dict, mapping::Dict, data_type:
944828 filter! (x -> first (x) in id_props_in_target_struct,
945829 prop_val_as_dict)
946830
947- if prop_symbol == :document
948- @info " prop_val_ids_values BEFORE util_replace_complex_types_by_id" prop_val_ids_values
949- end
950-
951831 prop_val_ids_values:: Dict = util_replace_complex_types_by_id (
952832 prop_val_ids_values,
953833 util_get_columns_selection_and_mapping (
954834 if ismissing (prop_val) dummy_propval else prop_val end
955835 ),
956836 _fieldtype)
957837
958- if prop_symbol == :document
959- @info " prop_val_ids_values AFTER util_replace_complex_types_by_id" prop_val_ids_values
960- end
961-
962-
963838 if length (idcols) != length (prop_val_ids_values)
964839 error_msg = " "
965840 error_msg *= " Problem while flattening property[$prop_symbol ] of"
0 commit comments