小编Jul*_*dez的帖子

Laravel mysql迁移错误

我最近格式化我的mac book pro,从github克隆了proyect并安装了我需要的东西,比如MySql和Sequel Pro我试图迁移数据库信息,但是我收到了这个错误:

   Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' (SQL: select * from information_schema.tables where table_schema = fisica and table_name = migrations)

  Exception trace:

  1   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'")
Run Code Online (Sandbox Code Playgroud)

版本:

Mysql 8.0.11

Laravel 5.6.12

PHP 7.1.14(cli)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=fisica
DB_USERNAME=xxx
DB_PASSWORD=xxx
Run Code Online (Sandbox Code Playgroud)

我从Sequel PRO GUI创建了数据库

php mysql laravel laravel-5.6

30
推荐指数
5
解决办法
1万
查看次数

Unhandle rejection promise async await chain

我在javascript中对async await相当新,所以这个问题可能是我不知道的.

我有这个

  async foo(req, res, next) {
    try {
      await scan(req.params.stack);
      res.send('ok');
    } catch (err) {
      res.status(500).send('fail');
    }
  }

async scan(stack) {
  try {
    const libs = [1,2,3];
    const promises = libs.map(async l => analyze(stack, l)
      .catch((err) => { throw new Error(err); }));
    return q.allSettled(promises)
      .then((results) => {
        const rejected = results.filter(r => r.state === 'rejected');
        if (rejected.length === results.length) throw new Error('Failed');
        return results;
      })
      .catch((err) => {
        throw new Error(err);
      });
  } catch (err) {
    throw new …
Run Code Online (Sandbox Code Playgroud)

node.js async-await

7
推荐指数
1
解决办法
222
查看次数

我应该避免在 Node js 上的每个 async/await 中使用 try catch 吗?

这是我在单元测试时遇到的一个设计问题。\n让我们深入研究示例:

\n

想象一下:

\n
async function foo()\xc2\xa0{\n    try {\n        return apiCall()\n    }\n    catch (e) {\n        throw new CustomError(e);\n    } \n}\n\n\n\nasync function bar() {\n    return foo()\n}\n\n\n\nasync function main() {\n    try {\n        await bar()\n    }catch(e) {\n        console.error(e)\n    }\n}\n\nmain()\n
Run Code Online (Sandbox Code Playgroud)\n

我们在这里看到什么?唯一没有 try-catch 块的函数是 bar。\n但是如果 foo 失败,它应该被 main catch 捕获。

\n

虽然像这样进行单元测试

\n
describe(\'testing bar\', () => {\n    it(\'foo should throw\', () => {\n        foo.mockImplementantion(() => { throw new CustomError(\'error\')});\n        bar()\n        .then((result) => console.log(result))\n        .catch((err) => { exepect(err).toBeInstanceOf(CustomError)}) // this is what we are …
Run Code Online (Sandbox Code Playgroud)

javascript node.js async-await jestjs

7
推荐指数
1
解决办法
9089
查看次数

标签 统计

async-await ×2

node.js ×2

javascript ×1

jestjs ×1

laravel ×1

laravel-5.6 ×1

mysql ×1

php ×1