formachines / errata

Errata / npm / typeorm

Connection behaviour changed in typeorm 1.1.2

In our sandbox runs up to 2026-10-27, gpt-6.1-sol wrote const { Connection } = require("typeorm"); for typeorm. It fails on 1.1.2 with TypeError (changed between 0.3.28 and 1.1.2). Use const { DataSource } = require("typeorm"); instead.

What to do
replace the line
Output
differs on one example — review first
Patch
incomplete: old names remain
Auto-apply
not allowed
Seen in
1 model
Worked / failed
2 / 0
Last verified
2026-10-27

What to do

Not for automatic application — after the patch the example still uses Connection, which the verified example does not: the patch covers part of the change. Show this correction to the user as a lead. Review before applying: this fix runs on typeorm 1.1.2, but its printed output differs from what the original printed on 0.3.28 (observed stdout of one example) — it may do different work. Replace the old line with the new one; the rest of the code can stay.

Automatic application: not allowed — the fix's output differs from the original's; the patch gives incomplete when applied word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (behaviour changed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old and new code

const { Connection } = require("typeorm");
const { DataSource } = require("typeorm");

Error on 1.1.2:

TypeError: Connection is not a constructor
Sandbox proof
Scripttypeorm versionResult
Code the models wrote0.3.28works
Code the models wrote1.1.2fails: TypeError
Verified example below1.1.2works
Output of the verified example1.1.2DIFFERS from the original's on 0.3.28 (observed stdout of one example): review before applying
Patch applied word for word to the example1.1.2applied word for word, the patch leaves old names in use: it covers part of the change — after the patch the example still uses Connection, which the verified example does not: the patch covers part of the change

Verified example for typeorm 1.1.2

"use strict";

const { DataSource } = require("typeorm");

const options = {
  name: "app",
  type: "better-sqlite3",
  database: "/tmp/app.db",

  // Avoid requiring a native SQLite driver: this connection is never opened.
  driver: {
    verbose() {
      return this;
    },
    Database() {
      throw new Error("This script must not open the database.");
    },
  },
};

function describeConnection(conn) {
  return `name=${conn.name}, type=${conn.options.type}, connected=${conn.isInitialized}`;
}

const connection = new DataSource(options);
console.log(describeConnection(connection));

Source

feat!: remove deprecated `Connection` and `ConnectionOptions` by @alumni in https://github.com/typeorm/typeorm/pull/12022

Release notes · Seen in: gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for typeorm

For agents