pgAdmin参数格式不能混用

时间:2019-05-13 10:13:57

标签: postgresql pgadmin

背景

  • Ubuntu 18.04
  • Docker中的Postgresql 11.2
  • pgAdmin4 3.5

有一列名为 alias 的列,其类型为AppWidgetProvider。在使用public class VplanWidget extends AppWidgetProvider { // ... static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId, final boolean force) { Log.d("WIDGET", "UPDATE FOR WIDGET " + appWidgetId + " with Nightmode " + VplanWidget.useNightmode(context, appWidgetId)); final CharSequence day = VplanWidgetConfigureActivity.loadDayPref(context, appWidgetId); CharSequence daystr; // Construct the RemoteViews object int layout = VplanWidget.useNightmode(context, appWidgetId) ? R.layout.vplan_widget_dark : R.layout.vplan_widget; final RemoteViews views = new RemoteViews(context.getPackageName(), layout); views.setOnClickPendingIntent(R.id.widget_fab, getPendingSelfIntent(context, SYNC_CLICKED, appWidgetId)); if (day.equals("today")) { daystr = context.getString(R.string.plan_today); } else { daystr = context.getString(R.string.plan_tomorrow); } final Vplan plan = new Vplan(context, day.toString()); views.setTextViewText(R.id.widget_title, daystr); MyTFGApi api = new MyTFGApi(context); if (!api.isLoggedIn()) { views.setTextViewText(R.id.widget_plan_empty, context.getString(R.string.widget_login_required)); views.setViewVisibility(R.id.widget_plan_empty, View.VISIBLE); views.setViewVisibility(R.id.widget_list_view, View.GONE); appWidgetManager.updateAppWidget(appWidgetId, views); return; } //views.setViewVisibility(R.id.widget_fab, View.GONE); long updateInt = force ? 0 : plan_update; Log.d("WIDGET", "UPDATE FORCE: " + force); views.setTextViewText(R.id.widget_plan_empty, context.getString(R.string.plan_empty)); views.setTextViewText(R.id.widget_title, context.getString(R.string.plan_loading)); appWidgetManager.updateAppWidget(appWidgetId, views); plan.load(new SuccessCallback() { @Override public void callback(boolean success) { //views.setViewVisibility(R.id.widget_fab, View.VISIBLE); Log.d("WIDGET", "UPDATE COMPLETED: " + success); if (success) { Date update = new Date(); update.setTime(plan.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("dd.MM. HH:mm", Locale.GERMANY); String diff = format.format(update); views.setTextViewText(R.id.widget_changed, context.getString(R.string.widget_last_update) + " " + diff); views.setTextViewText(R.id.widget_title, plan.formatDate()); if (plan.getEntries().size() == 0) { views.setViewVisibility(R.id.widget_plan_empty, View.VISIBLE); views.setViewVisibility(R.id.widget_list_view, View.GONE); } else { views.setViewVisibility(R.id.widget_plan_empty, View.GONE); views.setViewVisibility(R.id.widget_list_view, View.VISIBLE); } setRemoteAdapter(context, views, day.toString(), appWidgetId); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list_view); } // Instruct the widget manager to update the widget appWidgetManager.updateAppWidget(appWidgetId, views); } }, force, updateInt); } @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // There may be multiple widgets active, so update all of them for (int appWidgetId : appWidgetIds) { updateAppWidget(context, appWidgetManager, appWidgetId); } } private static void setRemoteAdapter(Context context, @NonNull final RemoteViews views, String day, int appWidgetId) { Intent intent; switch (day) { default: case "today": intent = new Intent(context, VplanWidgetServiceToday.class); break; case "tomorrow": intent = new Intent(context, VplanWidgetServiceTomorrow.class); break; } intent.putExtra("day", day); intent.setData(Uri.fromParts("content", String.valueOf(appWidgetId), null)); intent.putExtra("random", randomNum); randomNum++; views.setRemoteAdapter(R.id.widget_list_view, intent); } } 之前,已经在某些行上设置了值。那时一切都很好。

character varying[](64)

最近,当我想使用pgAdmin GUI 来增加价值时,如第一幅图中所示,第二幅图中出现了错误,提示不能混合参数格式< / strong>:

enter image description here

enter image description here

好吧,事实证明,如果在pgAdmin中使用 psql 查询工具之类的脚本插入值,则不会发生错误,即,仅当使用pgAdmin的 GUI

示例脚本:

psycopg2

但是由于GUI修改值要容易得多,所以真的想弄清楚它。有想法吗?

2 个答案:

答案 0 :(得分:9)

这是pgAdmin 4.17中的错误。

每当您编辑表中的char(n)[]varchar(n)[]单元格时,就会发生这种情况(尽管char[]varchar[]不受影响)。

应为fixed in 4.18

在此期间,您可以自己进行修复,而不会遇到太大麻烦。 pgAdmin4后端是用Python编写的,因此无需重建任何内容。您可以潜入并更改来源。

找到pgAdmin4的安装目录,然后在编辑器中打开web/pgadmin/tools/sqleditor/__init__.py。查找行:

typname = '%s(%s)[]'.format(

...并将其更改为:

typname = '{}({})[]'.format(

您需要重新启动pgAdmin4服务,以使更改生效。

答案 1 :(得分:0)

我无法使用Character Varying数据类型来使用此功能,但是一旦我将列数据类型转换为Text,它就可以使用。