diff --git a/src/queuecreator.cpp b/src/queuecreator.cpp
index 5615e8858d..c5d1bce794 100755
--- a/src/queuecreator.cpp
+++ b/src/queuecreator.cpp
@@ -1130,7 +1130,14 @@ bool QueueCreator_c::ParseQueryItem ( const CSphQueryItem & tItem )
{
CSphQueryItem tUuidItem = tItem;
tUuidItem.m_sExpr = sphGetUuidDocidName();
- if ( tUuidItem.m_sAlias.IsEmpty() || tUuidItem.m_sAlias==sphGetDocidName() )
+ bool bNeedsDocid = m_tQuery.m_eQueryType==QUERY_SQL && m_tQuery.m_dItems.any_of ( [&] ( const CSphQueryItem & tQueryItem )
+ {
+ const CSphColumnInfo * pField = m_tSettings.m_tSchema.GetField ( tQueryItem.m_sExpr.cstr() );
+ return tQueryItem.m_sExpr=="*" || ( pField && ( pField->m_uFieldFlags & CSphColumnInfo::FIELD_STORED ) );
+ } );
+ if ( bNeedsDocid )
+ tUuidItem.m_sAlias = sphGetUuidDocidName();
+ else if ( tUuidItem.m_sAlias.IsEmpty() )
tUuidItem.m_sAlias = sphGetDocidName();
return ParseResolvedQueryItem ( tUuidItem );
}
diff --git a/test/test_506/model.bin b/test/test_506/model.bin
new file mode 100644
index 0000000000..2c7e6b10cd
--- /dev/null
+++ b/test/test_506/model.bin
@@ -0,0 +1 @@
+a:1:{i:0;a:6:{i:0;a:2:{s:8:"sphinxql";s:73:"CREATE TABLE uuid_stored_text ( id uuid, merchant_id string, title text )";s:14:"total_affected";i:0;}i:1;a:2:{s:8:"sphinxql";s:77:"CREATE TABLE bigint_stored_text ( id bigint, merchant_id string, title text )";s:14:"total_affected";i:0;}i:2;a:2:{s:8:"sphinxql";s:136:"REPLACE INTO uuid_stored_text ( id, merchant_id, title ) VALUES ( '550e8400-e29b-41d4-a716-846655440001', 'merchant-1', 'Widget Alpha' )";s:14:"total_affected";i:1;}i:3;a:2:{s:8:"sphinxql";s:101:"REPLACE INTO bigint_stored_text ( id, merchant_id, title ) VALUES ( 1, 'merchant-1', 'Widget Alpha' )";s:14:"total_affected";i:1;}i:4;a:3:{s:8:"sphinxql";s:73:"SELECT id, merchant_id, title FROM uuid_stored_text WHERE MATCH('Widget')";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:36:"550e8400-e29b-41d4-a716-846655440001";s:11:"merchant_id";s:10:"merchant-1";s:5:"title";s:12:"Widget Alpha";}}}i:5;a:3:{s:8:"sphinxql";s:75:"SELECT id, merchant_id, title FROM bigint_stored_text WHERE MATCH('Widget')";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:1:"1";s:11:"merchant_id";s:10:"merchant-1";s:5:"title";s:12:"Widget Alpha";}}}}}
\ No newline at end of file
diff --git a/test/test_506/test.xml b/test/test_506/test.xml
new file mode 100644
index 0000000000..b71ad89fc3
--- /dev/null
+++ b/test/test_506/test.xml
@@ -0,0 +1,30 @@
+
+
+UUID id SQL projection preserves stored text fields
+
+
+
+
+
+
+
+
+searchd
+{
+
+ data_dir =
+ binlog_path =
+}
+
+
+
+
+ CREATE TABLE uuid_stored_text ( id uuid, merchant_id string, title text );
+ CREATE TABLE bigint_stored_text ( id bigint, merchant_id string, title text );
+ REPLACE INTO uuid_stored_text ( id, merchant_id, title ) VALUES ( '550e8400-e29b-41d4-a716-846655440001', 'merchant-1', 'Widget Alpha' );
+ REPLACE INTO bigint_stored_text ( id, merchant_id, title ) VALUES ( 1, 'merchant-1', 'Widget Alpha' );
+ SELECT id, merchant_id, title FROM uuid_stored_text WHERE MATCH('Widget');
+ SELECT id, merchant_id, title FROM bigint_stored_text WHERE MATCH('Widget');
+
+
+
diff --git a/test/test_518/test.xml b/test/test_518/test.xml
index 1738080c0b..ae0f31fa95 100644
--- a/test/test_518/test.xml
+++ b/test/test_518/test.xml
@@ -16,7 +16,7 @@
searchd
{
- data_dir =
+ data_dir =
auto_optimize = 0
}
diff --git a/test/test_520/test.xml b/test/test_520/test.xml
index 1919e8d7f5..cd5b352f55 100644
--- a/test/test_520/test.xml
+++ b/test/test_520/test.xml
@@ -16,7 +16,7 @@
searchd
{
- data_dir =
+ data_dir =
secondary_indexes = 0
}