diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-08 18:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-08 18:09:24 +0300 |
commit | 132b8909c81349a88317a00b94c1de97e2db4b74 (patch) | |
tree | 1f3bd9b2cb79ebceaa31694eb9f2df2333502937 /spec/support/database | |
parent | 73e7987ee3249d40057ee5f57b2aeb876f8f9c77 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/database')
-rw-r--r-- | spec/support/database/click_house/hooks.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/support/database/click_house/hooks.rb b/spec/support/database/click_house/hooks.rb index 27abd19dc3f..b970d3daf84 100644 --- a/spec/support/database/click_house/hooks.rb +++ b/spec/support/database/click_house/hooks.rb @@ -4,7 +4,13 @@ class ClickHouseTestRunner def truncate_tables ClickHouse::Client.configuration.databases.each_key do |db| - tables_for(db).each do |table| + # Select tables with at least one row + query = tables_for(db).map do |table| + "(SELECT '#{table}' AS table FROM #{table} LIMIT 1)" + end.join(' UNION ALL ') + + tables_with_data = ClickHouse::Client.select(query, db).pluck('table') + tables_with_data.each do |table| ClickHouse::Client.execute("TRUNCATE TABLE #{table}", db) end end |