@@ -14,20 +14,16 @@ mod ddl_tests;
1414#[ cfg( test) ]
1515mod query_tests;
1616
17- pub ( crate ) mod dsl;
1817pub ( crate ) mod index;
1918mod prune;
2019mod rollup;
21- pub ( crate ) mod value;
2220
2321use diesel:: deserialize:: FromSql ;
2422use diesel:: pg:: Pg ;
2523use diesel:: serialize:: { Output , ToSql } ;
2624use diesel:: sql_types:: Text ;
2725use diesel:: { connection:: SimpleConnection , Connection } ;
28- use diesel:: {
29- debug_query, sql_query, OptionalExtension , PgConnection , QueryDsl , QueryResult , RunQueryDsl ,
30- } ;
26+ use diesel:: { debug_query, sql_query, OptionalExtension , PgConnection , QueryResult , RunQueryDsl } ;
3127use graph:: blockchain:: BlockTime ;
3228use graph:: cheap_clone:: CheapClone ;
3329use graph:: components:: store:: write:: { RowGroup , WriteChunk } ;
@@ -54,7 +50,6 @@ use std::str::FromStr;
5450use std:: sync:: { Arc , Mutex } ;
5551use std:: time:: { Duration , Instant } ;
5652
57- use crate :: relational:: value:: { FromOidRow , OidRow } ;
5853use crate :: relational_queries:: {
5954 ConflictingEntitiesData , ConflictingEntitiesQuery , FindChangesQuery , FindDerivedQuery ,
6055 FindPossibleDeletionsQuery , ReturnedEntityData ,
@@ -63,10 +58,10 @@ use crate::{
6358 primary:: { Namespace , Site } ,
6459 relational_queries:: {
6560 ClampRangeQuery , EntityData , EntityDeletion , FilterCollection , FilterQuery , FindManyQuery ,
66- InsertQuery , RevertClampQuery , RevertRemoveQuery ,
61+ FindQuery , InsertQuery , RevertClampQuery , RevertRemoveQuery ,
6762 } ,
6863} ;
69- use graph:: components:: store:: { AttributeNames , DerivedEntityQuery } ;
64+ use graph:: components:: store:: DerivedEntityQuery ;
7065use graph:: data:: store:: { Id , IdList , IdType , BYTES_SCALAR } ;
7166use graph:: data:: subgraph:: schema:: POI_TABLE ;
7267use graph:: prelude:: {
@@ -177,12 +172,6 @@ impl From<String> for SqlName {
177172 }
178173}
179174
180- impl From < SqlName > for Word {
181- fn from ( name : SqlName ) -> Self {
182- Word :: from ( name. 0 )
183- }
184- }
185-
186175impl fmt:: Display for SqlName {
187176 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
188177 self . 0 . fmt ( f)
@@ -195,12 +184,6 @@ impl Borrow<str> for &SqlName {
195184 }
196185}
197186
198- impl PartialEq < str > for SqlName {
199- fn eq ( & self , other : & str ) -> bool {
200- self . 0 == other
201- }
202- }
203-
204187impl FromSql < Text , Pg > for SqlName {
205188 fn from_sql ( bytes : diesel:: pg:: PgValue ) -> diesel:: deserialize:: Result < Self > {
206189 <String as FromSql < Text , Pg > >:: from_sql ( bytes) . map ( |s| SqlName :: verbatim ( s) )
@@ -378,11 +361,9 @@ impl Layout {
378361 }
379362
380363 let table_name = SqlName :: verbatim ( POI_TABLE . to_owned ( ) ) ;
381- let nsp = catalog. site . namespace . clone ( ) ;
382364 Table {
383365 object : poi_type. to_owned ( ) ,
384366 qualified_name : SqlName :: qualified_name ( & catalog. site . namespace , & table_name) ,
385- nsp,
386367 name : table_name,
387368 columns,
388369 // The position of this table in all the tables for this layout; this
@@ -488,19 +469,11 @@ impl Layout {
488469 key : & EntityKey ,
489470 block : BlockNumber ,
490471 ) -> Result < Option < Entity > , StoreError > {
491- let table = self . table_for_entity ( & key. entity_type ) ?. dsl_table ( ) ;
492- let columns = table. selected_columns :: < Entity > ( & AttributeNames :: All , None ) ?;
493-
494- let query = table
495- . select_cols ( & columns)
496- . filter ( table. id_eq ( & key. entity_id ) )
497- . filter ( table. at_block ( block) )
498- . filter ( table. belongs_to_causality_region ( key. causality_region ) ) ;
499-
500- query
501- . get_result :: < OidRow > ( conn)
472+ let table = self . table_for_entity ( & key. entity_type ) ?;
473+ FindQuery :: new ( table. as_ref ( ) , key, block)
474+ . get_result :: < EntityData > ( conn)
502475 . optional ( ) ?
503- . map ( |row| Entity :: from_oid_row ( row , & self . input_schema , & columns ) )
476+ . map ( |entity_data| entity_data . deserialize_with_layout ( self , None ) )
504477 . transpose ( )
505478 }
506479
@@ -1389,21 +1362,6 @@ impl Column {
13891362 } )
13901363 }
13911364
1392- pub fn pseudo_column ( name : & str , column_type : ColumnType ) -> Column {
1393- let field_type = q:: Type :: NamedType ( column_type. to_string ( ) ) ;
1394- let name = SqlName :: verbatim ( name. to_string ( ) ) ;
1395- let field = Word :: from ( name. as_str ( ) ) ;
1396- Column {
1397- name,
1398- field,
1399- field_type,
1400- column_type,
1401- fulltext_fields : None ,
1402- is_reference : false ,
1403- use_prefix_comparison : false ,
1404- }
1405- }
1406-
14071365 fn new_fulltext ( def : & FulltextDefinition ) -> Result < Column , StoreError > {
14081366 SqlName :: check_valid_identifier ( & def. name , "attribute" ) ?;
14091367 let sql_name = SqlName :: from ( def. name . as_str ( ) ) ;
@@ -1496,9 +1454,6 @@ pub struct Table {
14961454 /// `Stats_hour`, not the overall aggregation type `Stats`.
14971455 pub object : EntityType ,
14981456
1499- /// The namespace in which the table lives
1500- nsp : Namespace ,
1501-
15021457 /// The name of the database table for this type ('thing'), snakecased
15031458 /// version of `object`
15041459 pub name : SqlName ,
@@ -1553,11 +1508,10 @@ impl Table {
15531508 . collect :: < Result < Vec < Column > , StoreError > > ( ) ?;
15541509 let qualified_name = SqlName :: qualified_name ( & catalog. site . namespace , & table_name) ;
15551510 let immutable = defn. is_immutable ( ) ;
1556- let nsp = catalog . site . namespace . clone ( ) ;
1511+
15571512 let table = Table {
15581513 object : defn. cheap_clone ( ) ,
15591514 name : table_name,
1560- nsp,
15611515 qualified_name,
15621516 // Default `is_account_like` to `false`; the caller should call
15631517 // `refresh` after constructing the layout, but that requires a
@@ -1576,7 +1530,6 @@ impl Table {
15761530 pub fn new_like ( & self , namespace : & Namespace , name : & SqlName ) -> Arc < Table > {
15771531 let other = Table {
15781532 object : self . object . clone ( ) ,
1579- nsp : self . nsp . clone ( ) ,
15801533 name : name. clone ( ) ,
15811534 qualified_name : SqlName :: qualified_name ( namespace, name) ,
15821535 columns : self . columns . clone ( ) ,
@@ -1651,10 +1604,6 @@ impl Table {
16511604 & crate :: block_range:: BLOCK_RANGE_COLUMN_SQL
16521605 }
16531606 }
1654-
1655- pub fn dsl_table ( & self ) -> dsl:: Table < ' _ > {
1656- dsl:: Table :: new ( self )
1657- }
16581607}
16591608
16601609#[ derive( Clone ) ]
0 commit comments