AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-8670745

yen's questions

Martin Hope
yen
Asked: 2024-12-17 06:25:08 +0800 CST

如何将 postgres 中的 timestamptz 列设置为一系列值来模拟真实世界的数据?

  • 5

基本上我有一个 created_at 列。所有条目都是今天创建的,因为它们是今天插入的。

为了完成一项功能的开发,我想模拟created_at过去 3 年中具有许多不同值的真实世界数据。

例如。

-- for all records
update sales_events set created_at = ... ???

我不太在意时间部分timestamptz。我也不关心某些日期是否重复。我只需要跨几年的日期。例如 2020 年至 2024 年。其中的任何地方。

sql
  • 1 个回答
  • 25 Views
Martin Hope
yen
Asked: 2024-10-01 01:02:18 +0800 CST

为什么我的 postgres 约束名称后缀与标准不同?

  • 4

在此 SO 回答中: PostgreSQL:默认约束名称

看起来我的外键(在创建表时未命名)应该默认为后缀_fkey...但似乎却默认为后缀_foreign。这是正常的吗?

我担心创建一个迁移,其中我假设约束名称并且它在我的环境中运行,然后在其他地方中断......

有什么办法可以确保我在任何环境下正确引用约束?

更新信息:

  • posgres 版本:16.4

  • 创建密钥的客户端:knex

  • 使用的完整 FK 命令:table.foreign('userId').references('users.id')

  • 带 \d 的 psql:

    很抱歉,我不允许发布我们代码库中的代码,因此这里是经过删节的代码:

Indexes:
    "***_pkey" PRIMARY KEY, btree (id)
    "***" UNIQUE CONSTRAINT, btree ("***Id", "***Id")
Foreign-key constraints:
    "***_***id_foreign" FOREIGN KEY ("***Id") REFERENCES ***(id)
    "***_userid_foreign" FOREIGN KEY ("userId") REFERENCES users(id)    <=== the column of interest
postgresql
  • 1 个回答
  • 30 Views
Martin Hope
yen
Asked: 2024-09-27 05:53:49 +0800 CST

内容安全策略:哪个约束来源最严格?

  • 5

语境

我在页面上有这个 CSP(在 vite react 应用程序中):

frame-src http://localhost:3080; style-src 'self' 'unsafe-inline' http://localhost:3080

页面上http://localhost:3080嵌入了一个 iframe。我无法控制该 iframe,因为它是由本地容器中运行的第三方应用生成的。iframe 自己的 CSP 标头类似于以下内容:

default-src 'none'; script-src 'self' https://maps.google.com https://accounts.google.com https://www.google-analytics.com 'sha256-xxxx=' 'sha256-xxxx=' 'sha256-xxxx='; child-src 'self' https://accounts.google.com; style-src 'self' 'nonce-xxxx' https://accounts.google.com; font-src *; img-src * 'self' data:; connect-src 'self' https://accounts.google.com service.us10.list-manage.com www.google-analytics.com https://service.example.com ; manifest-src 'self'; frame-ancestors 'none';

问题

在主 vite 应用程序中,当我尝试调整子 iframe 的高度时,浏览器中出现此错误:

Uncaught SecurityError: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "http://localhost:3000" from accessing a cross-origin frame.

还有这个错误(这很有趣,因为我没有直接对https://accounts.google.com做任何事情):

Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-xxxx'   https://accounts.google.com". Either the 'unsafe-inline' keyword, a hash ('sha256-xxxx='), or a nonce ('nonce-...') is required to enable inline execution.

问题

在上述情况下,vite 应用程序是否可以实现 CSP,从而允许更新 iframe 的高度,或者这是不可能的?我无法判断代码是否错误,或者这在技术上是否不可行。

iframe
  • 1 个回答
  • 16 Views
Martin Hope
yen
Asked: 2023-08-19 12:49:16 +0800 CST

golang testscript .txtar 语法,用于 stderr 或 stdout 中包含的文本

  • 7

我正在学习如何使用https://github.com/rogpeppe/go-internal testscript模块测试 cli 程序。

当我在.txtar文件中使用这一行时:

stderr /No help topic/gm

...实际的错误输出是:

No help topic for 'totalfoobar'

我得到了错误usage: stderr [-count=N] 'pattern'。

我看过这里的文档,说实话,很难理解。我没有看到任何解释-count=N。

我尝试了以下所有变体:

stderr -count=1 No help topic for 'totalfoobar'
stderr No help topic for 'totalfoobar'
stderr *No help topic*

无论字符串是什么,断言仍然会失败并出现相同的错误。

问:为了更灵活的测试,如何获取总 stderr / stdout 输出的子字符串?

go
  • 1 个回答
  • 16 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve