KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Protecting Vector Data If Rolling Back
PRODUCT: 4D | VERSION: 21 R5 | PLATFORM: Mac & Win
Published On: December 2, 2026
From 4D 21 R5, new vectors are 32-bit by default, and 4D 21 LTS cannot read them. Before a project returns to 21 LTS, its vectors should be converted to 64-bit in 21 R5.

21 LTS opens the data without any warning, but each 32-bit vector reads as an empty object {}. Similarity queries return no results, also without an error. The vector data remains on disk and can be recovered by reopening the data in 21 R5. The exception is when 21 LTS code writes to the vector field: that replaces the vector with {} for good, even if the code writes back the value it just read. Vector indexes are also lost on the round trip. They must be recreated after returning to 21 R5.

The following code, run in 21 R5, converts 32-bit vectors to 64-bit:
var $e : cs.ProductsEntity
For each ($e; ds.Products.query("embedding.precision = :1"; mk single precision))
  $e.embedding:=4D.Vector.new($e.embedding.toCollection(); mk double precision)
  $e.save()
End for each

Conversion does not restore the precision lost at 32-bit, but 21 LTS can read the result.
Note: this code must run in 21 R5. In 21 LTS the same query returns 0 without an error.

Some things to note:
  • To avoid the issue, vectors can be created with 4D.Vector.new($values; mk double precision) while a rollback is still possible.
  • After a rollback, 21 LTS code must not write to vector fields. The data should be reopened in 21 R5 and converted before returning to 21 LTS.
  • Under source control, opening the project in 21 LTS rewrites catalog.4DCatalog without a message. That change should not be committed.