Tedious: Azure MS SQL은 μ™„μ „νžˆ λ‹€λ₯Έ μ†Œμˆ˜λ₯Ό μ–»μŠ΅λ‹ˆλ‹€.

에 λ§Œλ“  2019λ…„ 12μ›” 12일  Β·  21μ½”λ©˜νŠΈ  Β·  좜처: tediousjs/tedious

ν•¨κ»˜ μ•ˆλ…•,

버전 6.5.0으둜 μ—…λ°μ΄νŠΈν•΄μ•Ό ν•˜λŠ” λ²”μœ„ 였λ₯˜ λ¬Έμ œκ°€ μžˆμ—ˆμŠ΅λ‹ˆλ‹€(6.6.1둜 μ—…λ°μ΄νŠΈν•˜λ €κ³  ν–ˆμ§€λ§Œ λ¬Έμ œκ°€ ν•΄κ²°λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. 문제 #1008 μ°Έμ‘°).

이제 높은 μ‹­μ§„μˆ˜ 값을 μ €μž₯ν•˜λ €κ³  ν•˜λ©΄ 훨씬 더 μž‘μ€ λ‹€λ₯Έ 숫자둜 λ°”λ€λ‹ˆλ‹€.

18728.4λŠ” 281.655926290으둜 λ°”λ€λ‹ˆλ‹€.
21345.4λŠ” 2898.655926290으둜 λ°”λ€λ‹ˆλ‹€.
625348.4λŠ” 16605.845567585둜 λ°”λ€λ‹ˆλ‹€.
&
34348.42λŠ” 15901.675926290으둜 λ°”λ€λ‹ˆλ‹€.

5926290 둜 λλ‚˜λŠ” λΉˆλ„κ°€ μ˜μ‹¬μŠ€λŸ½μŠ΅λ‹ˆλ‹€.
싀행이 μ½˜μ†”μ— κ²Œμ‹œλ˜λ©΄ μ‹€μ œλ‘œ μ˜¬λ°”λ₯Έ 값이 ν‘œμ‹œλ©λ‹ˆλ‹€. λ”°λΌμ„œ 쿼리 ν›„ db둜 λ³€κ²½λ©λ‹ˆλ‹€.

POSTing 12304.53은 μ‹€μ œλ‘œ μž‘λ™ν•˜λ©° DB에 κ·ΈλŒ€λ‘œ κΈ°λ‘λ©λ‹ˆλ‹€.

λ‚˜λŠ” 그것을 μ‘°ν•©ν•˜μ—¬ μ‚¬μš©ν•œλ‹€
μ†νŽΈ 5.15.1
νƒ€μ΄ν”„μŠ€ν¬λ¦½νŠΈ: 3.3.4000
λ…Έλ“œ: 10.15.3
Azure MS SQL λ°μ΄ν„°λ² μ΄μŠ€

ν•„λ“œλŠ” λ‹€μŒκ³Ό 같이 μ •μ˜λ©λ‹ˆλ‹€.

numResult: {
        type: DECIMAL(18, 9),
    },

이것은 λ˜ν•œ ms sql λ°μ΄ν„°λ² μ΄μŠ€κ°€ ν•΄λ‹Ή ν•„λ“œμ— λŒ€ν•΄ 슀슀둜 λ§ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

μΆ”κ°€ 정보가 ν•„μš”ν•˜λ©΄ μ•Œλ €μ£Όμ‹­μ‹œμ˜€.

Response needed

λͺ¨λ“  21 λŒ“κΈ€

κ·Έλž˜μ„œ λ°μ΄ν„°λ² μ΄μŠ€μ˜ λ‹€λ₯Έ 도ꡬλ₯Ό 톡해 값을 ν™•μΈν•˜λ©΄ 쓰여진 값이 잘λͺ»λœ 것인가? 이에 λŒ€ν•œ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€λ₯Ό μž‘μ„±ν•˜λ €κ³  ν•©λ‹ˆλ‹€.

κΈ€μŽ„, λ‚˜λŠ” 값을 κΈ°λ‘ν•˜κΈ° μœ„ν•΄ λ‚΄ nodeJs 연속화 μ„œλ²„λ₯Ό μ‚¬μš©ν•˜κ³  λ˜ν•œ 값이 μ˜¬λ°”λ₯Έ 쿼리λ₯Ό λ΄…λ‹ˆλ‹€.

그런 λ‹€μŒ DBeaverλ₯Ό μ‚¬μš©ν•˜μ—¬ DB에 잘λͺ»λœ 값이 ν‘œμ‹œλ©λ‹ˆλ‹€.
Sequelize와 ν•¨κ»˜ GETν•˜λ©΄ λ¬Όλ‘  잘λͺ»λœ 값도 λ°˜ν™˜λ©λ‹ˆλ‹€.

@arthurschreiber 참고둜 #1008μ—μ„œ μ„€λͺ…ν•œ 문제λ₯Ό μˆ˜μ •ν•œ ν›„ μ§€λ£¨ν•œ v6.6.1둜 μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. 이 λ¬Έμ œμ— λŒ€ν•΄ 차이λ₯Ό λ§Œλ“€μ§€ μ•Šμ•˜μ§€λ§Œ

이 λ¬Έμ œκ°€ λ°œμƒν•˜λŠ” 이유 및/λ˜λŠ” ν•΄κ²° 방법이 μ–΄λ–»κ²Œ μƒκ²ΌλŠ”μ§€ μ•Œλ €μ£ΌλŠ” μ‚¬λžŒμ΄ μžˆμŠ΅λ‹ˆκΉŒ?

@obermobber μ΅œλŒ€ν•œ 빨리 보도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€.

λ„€, 감사 ν•©λ‹ˆλ‹€ @arthurschreiber ! 정말 λ‚  미치게 ν•˜λŠ”κ΅¬λ‚˜ ν•˜ν•˜

@obermobber μž¬ν˜„μ„ μ‹œλ„ν–ˆμ§€λ§Œ μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.

이 λ¬Έμ œμ— κ²Œμ‹œν•œ 값을 μ‚¬μš©ν•˜μ—¬ test/integration/parameterised-statements-test.js 의 십진법 ν…ŒμŠ€νŠΈμ— μƒˆ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€λ₯Ό μΆ”κ°€ν–ˆμ§€λ§Œ SQLServer둜 μ˜¬λ°”λ₯΄κ²Œ μ „μ†‘λ©λ‹ˆλ‹€.

보고 μžˆλŠ” 문제λ₯Ό κ°„λ‹¨ν•œ ν…ŒμŠ€νŠΈ μ‚¬λ‘€λ‘œ μš”μ•½ν•  수 μžˆμŠ΅λ‹ˆκΉŒ? πŸ™‡

@arthurschreiber λΆ€λ„λŸ½μ§€λ§Œ 짧은 개발자 μƒν™œ λ™μ•ˆ 단 ν•œ λ²ˆλ„ ν…ŒμŠ€νŠΈλ₯Ό μž‘μ„±ν•œ 적이 μ—†μŠ΅λ‹ˆλ‹€(λ‚˜μœ μΌμ΄μ§€λ§Œ..). ν•˜μ§€λ§Œ ν•„μš”ν•œ λͺ¨λ“  정보λ₯Ό 기꺼이 μ œκ³΅ν•˜κ² μŠ΅λ‹ˆλ‹€. :(

μ§€λ£¨ν•œ ν…ŒμŠ€νŠΈλ₯Ό μœ„ν•΄ μ‚¬μš©ν•˜λŠ” ν”„λ ˆμž„μ›Œν¬λ‘œ μž‘μ„±λœ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€μΌ ν•„μš”λŠ” μ—†μŠ΅λ‹ˆλ‹€.

이 문제λ₯Ό μž¬ν˜„ν•  수 μžˆλŠ” μ΅œμ†Œν•œμ˜ μ½”λ“œλ§Œ 있으면 λ©λ‹ˆλ‹€. πŸ˜„

κ·Έλž˜μ„œ, λ‚˜λŠ” 그것이 λ§žμ•˜κΈ°λ₯Ό λ°”λžλ‹ˆλ‹€.

λ‚΄κ°€ μ‹€ν–‰ν•˜λŠ” λͺ¨λ“  것은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

@Post('/test')
    private async postDecimalTest(
        @Body() body: testCaseBody
    ) {
        try {
            const transaction = await sequelize.transaction();

            await DB.TestExecutionValues.create({
                testId: body.testId,
                numResult: body.numResult,
                strResult: body.strResult,
                enumResultSid: body.enumResult,
                unitId: body.unitId,
                ynPassed: body.ynPassed,
                comment: body.comment,
            }, { transaction });

            await transaction.commit();
            return { message: 'success posting test' };
        } catch (e) {
            console.log(e);
            throw e;
        }
    }

λ‚˜λŠ” 이 λͺΈμ„ 보낸닀:

{
    "testId": "LEVEL",
    "numResult": 465324.75,
    "strResult": "testcase",
    "enumResult": "1",
    "unitId": "mΒ³",
    "ynPassed": 1,
    "comment": ""
}

이것은 기둝된 κ²ƒμž…λ‹ˆλ‹€:

Executing (036ca06b3c1869b4851b): BEGIN TRANSACTION;
Executing (036ca06b3c1869b4851b): INSERT INTO [TestExecutionValues] ([testId],[numResult],[strResult],[enumResultSid],[unitId],[ynPassed],[comment]) OUTPUT INSERTED.* VALUES (<strong i="13">@0</strong>,<strong i="14">@1</strong>,<strong i="15">@2</strong>,<strong i="16">@3</strong>,<strong i="17">@4</strong>,<strong i="18">@5</strong>,@6);
Executing (036ca06b3c1869b4851b): COMMIT TRANSACTION;

그리고 이것은 DB에 쓰여진 λ‚΄μš©μž…λ‹ˆλ‹€:

{
                "testId": {
                    "id": "LEVEL",
                    "description": null
                },
                "numResult": 4156.148157261,
                "strResult": "testcase",
                "enumResult": {
                    "id": "#N/A",
                    "description": null
                },
                "unit": {
                    "id": "mΒ³",
                    "description": null
                },
                "ynPassed": true,
                "comment": ""
}

λ”°λΌμ„œ 465324.75 λŠ” 4156.148157261 둜 λ°”λ€λ‹ˆλ‹€.

λ‚˜λŠ” 그것이 μ€‘μš”ν•œ 경우 μš”μ²­μ— λŒ€ν•΄ λΌμš°νŒ… 컨트둀러 0.7.7을 μ‚¬μš©ν•©λ‹ˆλ‹€.
λ‹€λ₯Έ 정보가 ν•„μš”ν•˜μ‹­λ‹ˆκΉŒ? (μ•„λ‹ˆλ©΄ μ²˜μŒλΆ€ν„° κ·Έ λͺ¨λ“  것이 μ˜³μ•˜μŠ΅λ‹ˆκΉŒ?)

+++νŽΈμ§‘++++

ν…Œμ΄λΈ” μ •μ˜κ°€ ν•„μš”ν•  수 μžˆλ‹€κ³  μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€.

const TestExecutionValues = sequelize.define('TestExecutionValues', {
    sid: {
        type: INTEGER,
        autoIncrement: true,
        primaryKey: true,
        allowNull: false,
    },
    testId: {
        type: STRING,
        references: {
            model: Tests,
            key: 'testId',
        },
    },
    numResult: {
        type: DECIMAL(18, 9),
    },
    strResult: {
        type: STRING,
    },
    enumResultSid: {
        type: INTEGER,
        references: {
            model: EnumResults,
            key: 'sid',
        },
    },
    unitId: {
        type: STRING,
        references: {
            model: Units,
            key: 'unitId',
        },
    },
    ynPassed: {
        type: BOOLEAN,
    },
    comment: {
        type: TEXT,
    },
}, {
    timestamps: false,
});

μ§€λ£¨ν•œ 것 μœ„μ— μ†νŽΈμ„ μ‚¬μš©ν•˜λŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. μ΄λŠ” 일이 잘λͺ»λ  수 μžˆλŠ” μ›€μ§μ΄λŠ” 뢀뢄이 더 많기 λ•Œλ¬Έμ— 문제λ₯Ό μΆ”μ ν•˜κΈ° μ–΄λ ΅κ²Œ λ§Œλ“œλŠ” κ²½μš°κ°€ λ§ŽμŠ΅λ‹ˆλ‹€. 😞

DB.TestExecutionValues λŠ” μ–΄λ–»κ²Œ κ΅¬ν˜„λ˜λ‚˜μš”? πŸ€”

μ•„, 방금 μ •μ˜λ₯Ό κ²Œμ‹œν•˜μ…¨μŠ΅λ‹ˆλ‹€. λ‚΄κ°€ 무엇을 ν•  수 μžˆλŠ”μ§€ μ•Œμ•„λ³Ό 게.

λ„€, μ‹œν€„λΌμ΄μ œμ΄μ…˜μš© DBλ“œλΌμ΄λ²„λ‘œ μ§€λ£¨ν•˜κ²Œ μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€..
도움이 λ˜μ—ˆλ‹€λ©΄ 이 ν•„λ“œμ˜ DBeaver μŠ€ν¬λ¦°μƒ·μž…λ‹ˆλ‹€.

Bildschirmfoto 2019-12-14 um 12 20 05

μ—¬κΈ° λ‚΄κ°€ 방금 μ±„μ°μ§ˆν•œ μ˜ˆκ°€ μžˆμŠ΅λ‹ˆλ‹€.

const { Connection, Request, TYPES: { Decimal } } = require('tedious');

const connection = new Connection({
  // ...
});

connection.on('connect', () => {
  const request = new Request('CREATE TABLE #decimals (value decimal(18, 9))', (err) => {
    if (err) {
      throw err;
    }

    const request = new Request('INSERT INTO #decimals (value) VALUES (@value)', (err) => {
      if (err) {
        throw err;
      }

      const request = new Request('SELECT * FROM #decimals', (err) => {
        if (err) {
          throw err;
        }

        connection.close();
      });

      request.on('row', (columns) => {
        console.log(columns);
      });

      connection.execSql(request);
    });

    request.addParameter('value', Decimal, 18728.4, { precision: 18, scale: 9 });

    connection.execSql(request);
  });

  connection.execSqlBatch(request);
});

이것은 λ‚΄κ°€ λ‹€μ‹œ μ–»λŠ” 좜λ ₯μž…λ‹ˆλ‹€.

[ { value: 18728.4,
    metadata:
     { userType: 0,
       flags: 9,
       type: [Object],
       collation: undefined,
       precision: 18,
       scale: 9,
       udtInfo: undefined,
       dataLength: 17,
       schema: undefined,
       colName: 'value',
       tableName: undefined } } ]

λ‚˜λŠ” 이것이 tedious 의 문제라고 μƒκ°ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. πŸ€” λ°μ΄ν„°λ² μ΄μŠ€μ— λŒ€ν•΄ 이 λ™μΌν•œ μ½”λ“œλ₯Ό μ‹€ν–‰ν•˜κ³  λ‹€λ₯Έ κ²°κ³Όκ°€ λ‚˜νƒ€λ‚˜λŠ”μ§€ 확인할 수 μžˆμŠ΅λ‹ˆκΉŒ?

sequelize λ₯Ό 톡해 μ–΄λ–€ λ²„μ „μ˜ tedious λ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆκΉŒ?

흠... ν•΄λ³Όκ²Œμš” κ°μ‚¬ν•©λ‹ˆλ‹€!

ν˜„μž¬ λΆ™μ–΄ 있음
RequestError: Requests can only be made in the LoggedIn state, not the SentPrelogin state

ν•˜μ§€λ§Œ 이 문제λ₯Ό ν•΄κ²°ν•˜λ €κ³  ν•˜λŠ” λ™μ•ˆ μ—¬κΈ° λ‚΄ νŒ¨ν‚€μ§€ 잠금의 μŠ€λƒ…μƒ·μ΄ μžˆμŠ΅λ‹ˆλ‹€(지루함은 후속 쑰치의 쒅속성에 λ‚˜μ—΄λ˜μ§€ μ•ŠμœΌλ©° 이것은 λ‚΄ νŒ¨ν‚€μ§€ μž κΈˆμ—μ„œ μ§€λ£¨ν•¨μ˜ μœ μΌν•œ λ°œμƒμž…λ‹ˆλ‹€).

"tedious": {
      "version": "6.6.2",
      "resolved": "https://registry.npmjs.org/tedious/-/tedious-6.6.2.tgz",
      "integrity": "sha512-0Yziuys2h66dVlqMPJpNFciQ/N2VrgwY8o8TXyj4OZBaxrvqRPeMuTKZZVBFTGOjt/J15fR0fX0HBnCHjm7QWA==",
      "requires": {
        "@azure/ms-rest-nodeauth": "2.0.2",
        "@types/node": "^12.7.11",
        "@types/readable-stream": "^2.3.5",
        "bl": "^3.0.0",
        "depd": "^2.0.0",
        "iconv-lite": "^0.5.0",
        "jsbi": "^3.1.1",
        "native-duplexpair": "^1.0.0",
        "punycode": "^2.1.0",
        "readable-stream": "^3.4.0",
        "sprintf-js": "^1.1.2"
      },

μ•„, μ½”λ“œλ₯Ό λ‹€μŒκ³Ό 같이 λ³€κ²½ν•˜λ©΄

const { Connection, Request, TYPES: { Decimal } } = require('tedious');

const connection = new Connection({
  // ...
});

connection.on('connect', (err) => {
  if (err) {
    throw err;
  }

  const request = new Request('CREATE TABLE #decimals (value decimal(18, 9))', (err) => {
    if (err) {
      throw err;
    }

    const request = new Request('INSERT INTO #decimals (value) VALUES (@value)', (err) => {
      if (err) {
        throw err;
      }

      const request = new Request('SELECT * FROM #decimals', (err) => {
        if (err) {
          throw err;
        }

        connection.close();
      });

      request.on('row', (columns) => {
        console.log(columns);
      });

      connection.execSql(request);
    });

    request.addParameter('value', Decimal, 18728.4, { precision: 18, scale: 9 });

    connection.execSql(request);
  });

  connection.execSqlBatch(request);
});

연결에 μ‹€νŒ¨ν•˜λ©΄ 더 λ‚˜μ€ 였λ₯˜ λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ©λ‹ˆλ‹€.

그것은 μ‹€μ œλ‘œ λ§Žμ€ 도움이 λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ €λŠ” encryption μž¬μ‚°μ΄ μ—†μ—ˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒμ΄ λ§žμ•„μ•Όκ² μ£ ?

const connection = new Connection({
    server: 'server',
    authentication: {
        type: 'default',
        options: {
            userName: 'user',
            password: 'password',
        }
    },
    options: {
        encrypt: true,
        database: 'dbname'
    }
});

λ‚˜λŠ” DBeaver와 λ™μΌν•œ 자격 증λͺ…을 μ‚¬μš©ν–ˆκ³  μ•„λ¬΄λŸ° λ¬Έμ œκ°€ μ—†μ—ˆμ§€λ§Œ 항상 ConnectionError: Login failed for user 'user'. λ₯Ό λ°›μ•˜μŠ΅λ‹ˆλ‹€.
λ‚΄ 후속 μ—°κ²° μ„€μ •μ˜ μœ μΌν•œ 차이점은 λ°©μ–Έ μ˜΅μ…˜μ΄μ§€λ§Œ μ—¬κΈ°μ—μ„œ 찾지 λͺ»ν–ˆμŠ΅λ‹ˆλ‹€. http://tediousjs.github.io/tedious/api-connection.html

λͺ¨λ“  λ¬Έμ œμ— λŒ€ν•œ 유감!

λ§žμ•„μ•Ό ν•΄! μ—°κ²°ν•˜λ €λŠ” μ‚¬μš©μžκ°€ SQLServer μ‚¬μš©μžμž…λ‹ˆκΉŒ μ•„λ‹ˆλ©΄ Azure Active Directory 계정 μ‚¬μš©μžμž…λ‹ˆκΉŒ? (Azure λ°μ΄ν„°λ² μ΄μŠ€μ— λ‘˜ 쀑 ν•˜λ‚˜κ°€ μžˆμ„ 수 있음). default λŒ€μ‹  azure-active-directory-password λ₯Ό 인증 μœ ν˜•μœΌλ‘œ μ‚¬μš©ν•΄ λ³΄μ„Έμš”.

이것은 μ €μ—κ²Œ ν•œ 걸음 더 λ‹€κ°€κ°€κ²Œ ν–ˆμŠ΅λ‹ˆλ‹€. 이제 (node:67210) UnhandledPromiseRejectionWarning: ConnectionError: Security token could not be authenticated or authorized. λ₯Ό λ°›μŠ΅λ‹ˆλ‹€.
κ·ΈλŸ¬λ‚˜ 이것은 ν•˜λŠ˜μƒ‰ ꡬ성 μΈ‘λ©΄μ—μ„œ 더 λ§Žμ€ 문제인 것 κ°™μŠ΅λ‹ˆλ‹€. (적어도 ꡬ글이 μ €λ₯Ό μ§€μ‹œν•˜λŠ” κ³³μž…λ‹ˆλ‹€ ν•˜ν•˜)

이 λ¬Έμ œμ™€ κ΄€λ ¨ν•˜μ—¬ λͺ¨λ“  것이 μ§€λ£¨ν•˜μ§€ μ•Šμ€ λ‹€λ₯Έ κ³³μ—μ„œ 였λ₯˜λ₯Ό κ°€λ¦¬ν‚€λŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. κ·Έλž˜μ„œ μš°λ¦¬λŠ” 이것을 닫을 수 있고 μ•„λ§ˆλ„ μ†νŽΈν™”μ™€ κ΄€λ ¨λœ 문제λ₯Ό μ œκΈ°ν•  κ²ƒμž…λ‹ˆλ‹€.

@arthurschreiber μ‹œκ°„μ„ λ‚΄μ£Όμ…”μ„œ 정말 κ°μ‚¬ν•©λ‹ˆλ‹€!!

흠. μ™œ κ³„μ†ν•΄μ„œ Sequelizeλ₯Ό μ‚¬μš©ν•˜μ—¬ μ—°κ²°ν•  수 μžˆμ§€λ§Œ tedious λ₯Ό μ‚¬μš©ν•˜μ§€ μ•ŠλŠ”μ§€ κΆκΈˆν•©λ‹ˆλ‹€. 😬

이 문제λ₯Ό λ‹«κ³  tedious μ—μ„œ λ¬Έμ œκ°€ λ°œμƒν–ˆμŒμ„ ν™•μΈν•œ ν›„ λ‹€μ‹œ μ—¬μ‹­μ‹œμ˜€. πŸ™‡

λ‚˜λŠ” λ‹Ήμ‹ κ³Ό ν•¨κ»˜ 이 λ―ΈμŠ€ν„°λ¦¬λ₯Ό ν‘ΈλŠ” 것을 κ±°μ ˆν•˜μ§€ μ•Šμ„ κ²ƒμž…λ‹ˆλ‹€ ν•˜ν•˜! ν•˜μ§€λ§Œ λ‚˜λŠ” 더 이상 λ‹Ήμ‹ μ˜ μ‹œκ°„μ„ 보내고 싢지 μ•Šμ•˜μŠ΅λ‹ˆλ‹€ πŸ˜ƒ

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰